Java's POI simple operation

Source: Internet
Author: User

1 2/** First, simply read the execl steps:3 * 1, through the stream to read execl coexist and put into memory;4 * 2. Read the EXECL document stream stored in memory through the Workbookfactory workbook factory and create a workbook5 * 3, through the workbook to get inside each of the sheet documents6 * 4, each sheet document to obtain the inside of each line7 * 5, each row to get each cell8 * 6, through the cell to get the value inside9 * Ten * workbookfactory-->workbook (xssfworkbook\hssfworkbook) One * |--sheet (Xssfsheet\hssfsheet) A * |--row (Xssfrow\hssfrow) - * |--cell (Xssfcell\xssfcell) - * |--cellvalue the */ -  -InputStream FIS =NewFileInputStream ("f:/execl/readtest1.xlsx");//to read the EXECL document first -Workbook wb = workbookfactory.create (FIS);//Use the Workbookfactory workbook factory to create a workbook by reading the Execl document Flow +Sheet sheetat = wb.getsheetat (0);//get every sheet document in the workbook through a workbook -Row row = Sheetat.getrow (0);//get each row through each sheet +Cell cell = Row.getcell (1);//get each cell from each row A Doubleval = Cell.getnumericcellvalue ();//get the value inside by cell at  - // ============================================================================ -  - /** - * First, simply write the execl steps: - * 1. Create a blank execl document in memory by streaming in * 2. Create a workbook workbook - * 3. Create a sheet document from the workbook to * 4. Create a line from the sheet document + * 5. Create a cell by one line - * 6. Set the value inside the cell the * 7. Write content to a blank ecxecl document stream in memory by workbook workbook * *  $ * Workbook-->xssfworkbook\hssfworkbookPanax Notoginseng * |--sheet (Xssfsheet\hssfsheet) - * |--row (Xssfrow\hssfrow) the * |--cell (Xssfcell\hssfcell) + * |--cellvalue A */ the  +OutputStream OS =NewFileOutputStream ("f:/execl/writetest1.xlsx");//Create a blank execl document in memory by streaming -Workbook WB =NewXssfworkbook ();//Create a workbook workbook $Sheet Sheet = Wb.createsheet ();//Create a sheet document from a workbook $Row row = Sheet.createrow (0);//Create a line by sheet a document -Cell cell = Row.createcell (0,cell.cell_type_string);//Create a cell by one line -Cell.setcellvalue ("execl Write test haha ...");//set the value inside the cell theWb.write (OS);//write content to a blank ecxecl document stream in memory by workbook workbooks - os.close ();Wuyi  the  

Java POI simple operation

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.