Create an Excel file stream

Source: Internet
Author: User

String [] STR = new string [] {…}; // Create a pre-selected column header

Hssfsheet sheet = Workbook. createsheet ("sheet1 ");

Hssfrow ROW = sheet. createrow (0 );
For (INT I = 0; I <Str. length; I ++ ){
Hssfcell cell = row. createcell (short) I );
Cell. setcellvalue (New hssfrichtextstring (STR [I]);
}

// Encapsulate the data into the Map <integer, Map <integer, string> type and write data in two cycles
Map <integer, Map <integer, string> map = (Map <integer, Map <integer, string>) helper. getresult ("map ");
// Create an Excel report with the same columns as the String Array
For (Map. Entry <integer, Map <integer, string> entry: map. entryset ()){
// Create row
Hssfrow _ ROW = sheet. createrow (entry. getkey ());
Map <integer, string> value = entry. getvalue ();
// Create a cell
For (Map. Entry <integer, string> _ entry: value. entryset ()){
Hssfcell _ cell = _ row. createcell (_ entry. getkey (). duplicate value ());
_ Cell. setcellvalue (New hssfrichtextstring (_ entry. getvalue ()));
}
}
}

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.