Java + Excel learning

xiaoxiao2021-04-07  409

In the past two days, the method of Java Excel first needs to go to the online next jxl.jar package I write the practice code as follows: (Note that the picture insteit into yourself) Import java.io. *; Import java.util.randem; import jxl. *; import jxl.format.underLineStyle; import jxl.write. *; import jxl.write.Number; import jxl.write.boolean; public class createxl {Public createXL () {} public static void main (string [] args) {// reads Excel //createxl.readexcel ("D: /Abc.xls "); // Create new Excel Createxl.writeExcel (" D : // update Excel Createxl.UpdateExcel ("D: /New.xls");} // jxl There is no additional data sheet for the time being, here is a small approach to achieve this purpose, not suitable for large data update // here by overwriting the original file to update the public static void updateExcel (String filePath) {try {Workbook rwb = Workbook.getWorkbook (new file (filePath));!. WritableWorkbook wwb = Workbook.createWorkbook ( New file ("D: /New.xls"), RWB); // Copy Writablesheet WS = Wwb.getsheet (0); WritableCell WC = WS.GetWritableCell (0); // Judgment the type of cell, do Appearance Translation of Label Label = (Label) WC; Label.SetString ("The Value Has Been Modified"); wwb.write (); wwb.close (); rwb.close ();} catch (Exception E) {e) .printStackTrace ();}} public static void writeExcel (String filePath) {try {// create a workbook WritableWorkbook wwb = Workbook.createWorkbook (new File (filePath)); // Create worksheet WritableSheet ws = wwb.createSheet ( " Sheet1 ", 0); //system.out.println ("create ok!"); // Add label text Random RND =

NEW Random ((New Date ()). getTime ()); int forNumber = rnd.nextint (100); for (int i = 0; i

转载请注明原文地址:https://www.9cbs.com/read-132497.html

New Post(0)