One, create an Excel file
Package test;
Generating classes for Excel
Import Java.io.File; Import JXL. Workbook;
Import Jxl.write.Label; Import Jxl.write.WritableSheet;
Import Jxl.write.WritableWorkbook;
public class Createexcel {
public static void Main (String args[]) {
try {
Open File
Writableworkbook book = Workbook.createworkbook (New File ("Test.xls"));
Generate a worksheet named "first page", parameter 0 indicates this is the first page
Writablesheet sheet = book.createsheet ("First page", 0);
Named cell position in the construction of a label object is the first column in the first row (0,0)
And the cell content is test label label = new label (0, 0, "test");
Add a defined cell to the worksheet Sheet.addcell (label);
Jxl.write.Number number = new Jxl.write.Number (1, 0, 555.12541);
Sheet.addcell (number); Writing data and closing files
Book.write ();
Book.close ();
}
catch (Exception e) {
System.out.println (e);
}
}
}
After the compilation is executed, an Excel file is generated.
Java uses JXL to export/Generate EXCEL "my"