【发布时间】:2021-10-29 04:59:38
【问题描述】:
我想逐列写入 Excel 文件,但我不知道如何执行此操作。有可能做到吗?我查看了文档,没有看到逐列编写的方法。 这是我的代码:
private void writeColumnByColumn() throws IOException {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet();
String[] strings = {"a", "b", "c"};
Row row = sheet.createRow(0);
for (int i = 0; i < 3; i++) {
// here i want to write "a" in the first column, "b" in the second and "c" in the third
}
FileOutputStream outputStream = new FileOutputStream("ok.xlsx");
try (outputStream) {
workbook.write(outputStream);
}
}
【问题讨论】:
标签: java excel apache-poi fileoutputstream xssf