Npoi format setting 1

Source: Internet
Author: User
Using npoi. SS. usermodel; using npoi. hssf. usermodel; // create execl iworkbook hssfworkbook = new hssfworkbook (); // create a sheet hssfworkbook. createsheet ("sheet1"); // filestream file = new filestream (@ "test.xls", filemode. create); hssfworkbook. write (File); file. close (); // to create a cell, you must first create the row where the cell is located. For example, the following code creates row 0th: isheet sheet1 = hssfworkbook. createsheet ("sheet1"); irow row1 = sheet1.createrow (0); // After the row is created, you can create a cell, for example, create a cell at the A1 position: row1.createcell (0 ). setcellvalue ("This is a sample"); // or sheet1.getrow (0 ). createcell (0 ). setcellvalue ("This is a sample"); // set header text to set the header s1.header. center = "this is a test sheet"; // set footer text to set the footer s1.footer. left = "Copyright npoi team"; s1.footer. right = "created by 123"; // set date format to set the cell format icellstyle cellstyle = hssfworkbook. createcellstyle (); idataformat format = hssfworkbook. createdataformat (); cellstyle. dataformat = format. getformat ("yyyy-mm-dd"); // cellstyle. dataformat = hssfdataformat. getbuiltinformat ("0.00"); the cell format is "0.00", "¥ #, #0" USD, and "0.00%" percentage shows cell. cellstyle = cellstyle; // merge cell irow ROW = sheet. createrow (0); icell cell = row. createcell (0); cell. setcellvalue ("Sales Report"); icellstyle style = hssfworkbook. createcellstyle (); style. alignment = horizontalalignment. center; ifont font = hssfworkbook. createfont (); font. fontheight = 20*20; style. setfont (font); cell. cellstyle = style; sheet. addmergedregion (new region (0, 0, 0, 5 ));

Npoi format setting 1

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.