Public static void batchWriteExcel (String sourceExcelPath, String targetExcelPath) {
InputStream is=null;
//create a new output stream
OutputStream OS=null;
Workbook workbook=null;
Try {
Is=ExcelUtils. Class. GetResourceAsStream (sourceExcelPath);
Workbook=WorkbookFactory. Create (is);
//get the second sheet
Sheet secondSheet=workbook. GetSheetAt (1);
ListCellDatas=ApiUtils. GetCellDataList ();
For (CellData CellData: cellDatas) {
Int rowNo=cellData. GetRowNo ();//line number
Int coloumNo=cellData. GetColumnNo ();//column number
The String content=cellData. GetContent ();//to write the contents of the
//get to write lines
The Row currentRow=secondSheet. GetRow (rowNo - 1);
//get to write columns
Cell Cell=currentRow. GetCell (coloumNo - 1, MissingCellPolicy CREATE_NULL_AS_BLANK);
Cell. SetCellType (CellType. STRING);
//set to write the contents of the
Cell. SetCellValue (content);
}
//write back to excel
OS=new FileOutputStream (new File (targetExcelPath));
Workbook. Write (OS);
} the catch (Exception e) {
e.printStackTrace();
} the finally {
Close (workbook, OS, is);
}
}
Batch written document, called the empty, get the behavior have bosses can save a life