Java uses JXL to export/Generate EXCEL "my"

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.