欢迎分享,转载请注明来源:内存溢出
poi导出excel出错org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException:Fail to save
完整例子供参考: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();}}}
赞
(0)
打赏
微信扫一扫
支付宝扫一扫
24上香图解和72上香图解有什么区别
上一篇
2023-05-09
如何在pc上搭建树莓派开发环境_树莓派搭建服务器可以实现什么
下一篇
2023-05-09
评论列表(0条)