
完整例子供参考: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条)