Using the poi3.9 jar to output Excel

Source: Internet
Author: User

Get the path to the template file storage

Readfilepath = Servletactioncontext.getservletcontext (). Getrealpath (Exceltemplatefilepath);

Get the path of temporary template file storage

Savefilepath = Servletactioncontext.getservletcontext (). Getrealpath (Tempsaveexceltemplatefilepath);

Create temporary template file to store the path

Ipfolder = new File (Savefilepath);
if (ipfolder.exists ()) {
if (DeleteFile (ipfolder.tostring ())) {
Ipfolder.mkdir ();
}
} else {
Ipfolder.mkdir ();
}

Copy the template file to the temporary template file to store the path

CopyFile (New File (Readfilepath), ipfolder);

Read template files in a temporary path into a character stream

FileInputStream FileInputStream = new FileInputStream (Ipfolder);

Create Workbook
Workbook book = workbookfactory.create (FileInputStream);

Get the first sheet of a workbook
Sheet Sheet = book.getsheetat (0);

Write Excel files using POI
The jar package required for the struts version
Struts1. X Poi-3.9-20121203.jar,poi-ooxml-3.9-20121203.jar,poi-ooxml-schemas-3.9-20121203.jar
struts2.3 Poi-3.9-20121203.jar,poi-ooxml-3.9-20121203.jar,poi-ooxml-schemas-3.9-20121203.jar
/ooxml-lib/dom4j-1.6.1.jar,/ooxml-lib/xmlbeans-2.3.0.jar

Using the poi3.9 jar to output Excel

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.