2 回答
TA贡献1877条经验 获得超1个赞
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet();
Row headerRow = sheet.createRow(0);
headerRow.createCell(0).setCellValue("Setupid");
headerRow.createCell(1).setCellValue("Request");
int cellCount = 10;
for (int i = 1; i <= cellCount; i++) {
Row row = sheet.createRow(i);
row.createCell(0).setCellValue("cell " + i);
row.createCell(1).setCellValue("cell " + i);
}
File file = new File(System.getProperty("user.dir")
+ "/src/main/uat/testdata/FreeTestData.xlsx");
if(file.exists()) {
file.delete();
}
file.createNewFile();
FileOutputStream fos = new FileOutputStream(file);
workbook.write(fos);
fos.close();
workbook.close();
TA贡献1803条经验 获得超3个赞
我认为你的 for 循环不正确
for(int i=1; i<=n; i++){
它应该是
for(int i=1; i<=lastRow; i++){
添加回答
举报