Java uses f1j9swing to generate Excel files

Source: Internet
Author: User

Project needs to introduce F1j9swing.jar package


Package Sinosoft_xsy;import Java.io.ioexception;import Com.f1j.ss.bookmodelimpl;import Com.f1j.ss.CellFormat; Import Com.f1j.ss.constants;import Com.f1j.ss.writeparams;import Com.f1j.util.f1exception;public class Sinosoft { static CellFormat Mcellformat = new CellFormat (), static cellformat mlefttopcf = new CellFormat (); static CellFormat MINPUTC F = new CellFormat ();p ublic static void Main (string[] args) {testexcel ();} /** * Use f1j9swing to generate Excel */public static void Testexcel () {Bookmodelimpl book = new Bookmodelimpl (); Bookmodelimpl Modelbook = new Bookmodelimpl (), try {book.initworkbook (); Setcellformat ();//Read existing template Modelbook.read ("E:\ \workspace3.7\\gs_acc\\hkcwweblogic\\account\\yd_work\\bulletinreport\\bulletinreport_1.xls ");//read template Excel, All of the cell's styles are defined here, each generated by a sheet on the copy, the easiest book.copyrange (0, 0, Modelbook.getlastrow (), Modelbook.getlastcol (), Modelbook, 0, 0, Modelbook.getlastrow (), Modelbook.getlastcol (), constants.ecopyall); for (int i = 0; I <= modelbook.get Lastcol (); i++) {Book.setcolwiDTH (I, Modelbook.getcolwidth (i));//Set the column width, which is the width of the columns in the template, the resulting Excel column is also much wider}book.settext (2,0, "May 21, 2015"); for (int m = 9; m <= 34; m++) {//The starting line and end line of the XLS to be displayed System.out.println (m), Book.setnumber (M-1, 3, one); Book.setnumber (M-1, 4, 11); Book.setnumber (M-1, 5, 11);} Book.setsheetname (0, "Quarterly Express"); book.insertsheets (0, 1);//Excel file Output Book.write ("e:\\workspace3.7\\gs_acc\\ Hkcwweblogic\\account\\yd_work\\bulletinreport\\bulletinreport_111111.xls ", New Writeparams ( BOOKMODELIMPL.EFILEEXCEL97));//Excel file Output} catch (OutOfMemoryError e) {e.printstacktrace ();} catch (F1exception e) { E.printstacktrace ();} catch (IOException e) {e.printstacktrace ();}} public static void Setcellformat () throws f1exception{//Generate cell format mcellformat.setleftborder (Cellformat.eborderthin); Mcellformat.setrightborder (Cellformat.eborderthin); Mcellformat.settopborder (Cellformat.eborderthin); Mcellformat.setbottomborder (Cellformat.eborderthin); Mcellformat.setverticalinsideborder (CellFormat.eBorderThin ); Mcellformat.setfontname ("Song Body");//upper-left corner format mLefttopcf.setfontname ("Song Body"); mlefttopcf.setfontsize (200);//10 Mlefttopcf.setfontbold (TRUE);// Bold Mlefttopcf.sethorizontalalignment (Cellformat.ehorizontalalignmentleft);//Left Mlefttopcf.setverticalalignment ( Cellformat.everticalalignmentcenter)///Vertical Center//Input data cell format minputcf.setleftborder (Cellformat.eborderthin); Minputcf.setrightborder (Cellformat.eborderthin); Minputcf.settopborder (Cellformat.eborderthin); Minputcf.setbottomborder (Cellformat.eborderthin); Minputcf.setfontname ("The song Body"); minputcf.setfontsize (200); Minputcf.sethorizontalalignment (cellformat.ehorizontalalignmentcenter);//Center Minputcf.setverticalalignment ( Cellformat.everticalalignmentcenter);//Vertical Center}}

  

Java uses f1j9swing to generate Excel files

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.