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