Poi operation Excel Style

Source: Internet
Author: User

Poi operation Excel Style

Package COM. cloud. poi. utils; import Java. io. file; import Java. io. fileoutputstream; import Java. io. ioexception; import Java. io. outputstream; import Org. apache. poi. SS. usermodel. cell; import Org. apache. poi. SS. usermodel. cellstyle; import Org. apache. poi. SS. usermodel. row; import Org. apache. poi. SS. usermodel. sheet; import Org. apache. poi. SS. usermodel. workbook; import Org. apache. poi. xssf. usermodel. xssfcell; import Org. Apache. poi. xssf. usermodel. xssffont; import Org. apache. poi. xssf. usermodel. xssfworkbook;/*** poi operation Excel Style * @ author Henry */public class poiexcelstylealter {public static void main (string [] ARGs) throws ioexception {string filepath = "D: /"; string filename =" test "; string filetype =" XLSX "; workbook = new xssfworkbook (); // create a workbook sheet = workbook. createsheet ("test"); // create a sheetsheet. setcolu Mnhidden (2, true); // hide the 1st columns. The column "row" = "sheet" is not displayed in Excel. createrow (1); cell = row. createcell (1); cellstyle style = workbook. createcellstyle (); // create a style object style. setwraptext (true); // set Automatic newline xssffont font = (xssffont) workbook. createfont (); // create the font object. setfontname (""); style. setfont (font); cell. setcellstyle (style); style. setlocked (true); // sets whether the style referenced by the cell locks the cell. setcelltype (xssfcell. cell_type_string); // set the ticket Cell. setcellvalue ("test I'm tired now, you know, I'm really tired. I am very tired and tired !~ I tiger you! "); File = new file (filepath + filename + ". "+ filetype); outputstream stream = new fileoutputstream (File); workbook. write (Stream); stream. close ();}}

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.