poi导出excel出错org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException:Fail to save

poi导出excel出错org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException:Fail to save,第1张

完整例子供参考:importjavaioFile;importjavaioFileOutputStream;importorgapachepoissusermodelCell;importorgapachepoissusermodelCellStyle;importorgapachepoissusermodelIndexedColors;importorgapachepoissusermodelRow;importorgapachepoissusermodelSheet;importorgapachepoissusermodelWorkbook;importorgapachepoixssfusermodelXSSFWorkbook;publicclassTestClass{publicstaticvoidmain(String[]args){Workbookwb=newXSSFWorkbook();Sheetsheet=wbcreateSheet("coverageData");intrownum=0,cellnum=0;Rowrow1=sheetcreateRow((short)rownum++);//SetColorstylestartCellStylerow1style=wbcreateCellStyle();row1stylesetFillBackgroundColor(IndexedColorsLIGHT_GREENgetIndex());row1stylesetFillPattern(CellStyleBIG_SPOTS);//SetColorstyleendCellcell10=row1createCell((short)cellnum++);cell10setCellStyle(row1style);cell10setCellValue("celldata");try{//WritetheworkbookinfilesystemFileOutputStreamout=newFileOutputStream(newFile("Spreadsheetxlsx"));wbwrite(out);outclose();Systemoutprintln("Spreadsheetxlsxwrittensuccessfullyondisk");}catch(Exceptione){eprintStackTrace();}}}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/10576719.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-09
下一篇 2023-05-09

发表评论

登录后才能评论

评论列表(0条)

保存