我遇到需要在 Excel 单元格内添加表格或行的情况。
我用谷歌搜索但没有找到任何东西。
请帮助我知道该怎么做。
最佳答案
你在找这个吗?
Workbook wb = new HSSFWorkbook();
//Workbook wb = new XSSFWorkbook();
CreationHelper createHelper = wb.getCreationHelper();
Sheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
Row row = sheet.createRow((short)0);
// Create a cell and put a value in it.
Cell cell = row.createCell(0);
cell.setCellValue(1);
// Or do it on one line.
row.createCell(1).setCellValue(1.2);
row.createCell(2).setCellValue(
createHelper.createRichTextString("This is a string"));
row.createCell(3).setCellValue(true);
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
关于java - Apache POI 在 Excel 中的单元格内创建行或表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24449145/