Java uses poi to perform simple _ write _ Operations on Execl, and java uses poiexecl
1 public class WriteExecl {2 3 @ Test 4 public void writeExeclTest () throws Exception {5 OutputStream OS = new FileOutputStream ("F:/execl/writeTest2.xlsx "); 6 // Workbook wb = new HSSFWorkbook (); // create a 2003 version of Execl 7 Workbook wb = new XSSFWorkbook (); // create an Execl 8 9 CellStyle cellStyle = wb for Versions later than 2007. createCellStyle (); // create a style 10 cellStyle. setBorderLeft (CellStyle. BORDER_THIN); // The cell Border width is 11 cellStyle. setBorderRight (CellStyle. BORDER_THIN); // The cell Border width is 12 cellStyle. setBorderTop (CellStyle. BORDER_THIN); // the false width of the cell border 13 cellStyle. setBorderBottom (CellStyle. BORDER_THIN); // cell Border Width 14 cellStyle. setAlignment (CellStyle. ALIGN_CENTER); // horizontally centered 15 cellStyle. setverticalignment (CellStyle. VERTICAL_CENTER); // center vertically 16 cellStyle. setBottomBorderColor (IndexedColors. RED. getIndex (); // set the bottom border to Red 17 cellStyle. setFillForegroundColor (IndexedColors. DARK_YELLOW.getIndex (); // you can specify 18 cellStyle for the foreground. setFillPattern (CellStyle. SOLID_FOREGROUND); // set the cell fill color to 19 20 Sheet sheet = wb. createSheet ("first sheet"); // create a named sheet21 sheet. setdefacolumcolumnwidth (1000); // sets the default width of 22 sheet in sheet. setDefaultRowHeight (short) 800); // set the default height of 23 24 Row row = sheet in sheet. createRow (0); // create a row with 25 rows. createCell (0, Cell. CELL_TYPE_BLANK); // create a blank cell 26 row. createCell (1, Cell. CELL_TYPE_BOOLEAN ). setCellValue (true); // create a boolean cell 27 row. createCell (2, Cell. CELL_TYPE_FORMULA ). setCellValue (3.141592653); // create a formula Cell 28 row. createCell (3, Cell. CELL_TYPE_NUMERIC ). setCellValue (0); // create a numeric cell 29 row. createCell (4, Cell. CELL_TYPE_STRING ). setCellValue ("String... "); // create a string cell 30 row. setRowStyle (cellStyle); // set the row style 31 wb. write (OS); // write the orkbook workbook 32 OS to Execl in the memory. close (); // remember to close the stream and release the resource 33} 34}