Write an Excel file import java.io.*;import Jxl.*;import java.lang.boolean;public class writetoexcel{public Boolean run (stri ng TargetFile) {try{Jxl.write.WritableWorkbook WWB = Workbook.createworkbook (new File (targetfile)); Jxl.write.WritableSheet ws = Wwb.createsheet ("MySheet1", 0); for (int i = 0, I < i++) {for (int j = 0; J <; J + +) {Jxl.write.Label LABELC = New Jxl.write.Label (J, I, "cell[" +i+ "," +j+ "]"); Ws.addcell (LABELC); }} wwb.write (); Wwb.close ();//Remember to close to free space return true; } catch (Exception e) {e.printstacktrace (); return false; }}//reads an Excel file (created by the code above) and outputs the contents of import Java.io.*;import Jxl.*;import JXL on the console. Workbook;import Java.lang.boolean;public class Readfromexcel {public Boolean run (String targetfile) {try{ InputStream is = new FileInputStream (TARGETFILE); Jxl. Workbook RWB = Workbook.getworkbook (IS); Sheet rs = rwb.getsheet (0); for (int i = 0, I < i++) {for (int j = 0; J <; J + +) {cell cell = Rs.getcell (j , i);//The first digit is the column number, the second digit is the line number System.out.print (cell.getcontents () + "\ r"); } System.out.println (); } rwb.close (); return true; } catch (Exception e) {e.printstacktrace (); return false; } }}
Java implements Excel data import and Export