小编sha*_*rky的帖子

使用apache poi循环数组数据

我是java和Apache POI的初学者.

所以现在我想要实现的是我想在Days列下逐行(垂直)循环数组:

公众假期日期日期类

public static void main(String[] args) {

    XSSFWorkbook workbook = new XSSFWorkbook();

    XSSFSheet sheet = workbook.createSheet();

    String[] days = { "SU", "MO", "TU", "WED", "TH", "FR", "SA" };

    Row row = sheet.createRow(0);
    row.createCell(0).setCellValue("Public Holidays");
    row.createCell(1).setCellValue("Days");
    row.createCell(2).setCellValue("Date");
    row.createCell(3).setCellValue("Class");

    int numRows = sheet.getFirstRowNum();
    int numCols = sheet.getRow(0).getLastCellNum();

    for (int i = 1; i < 7; i++) {

        Row row2 = sheet.createRow(i);
        Cell cell = row.createCell(1);
        cell.setCellValue(days);

    }

    try {

        FileOutputStream out = new FileOutputStream(new File("C:xx"));

        workbook.write(out);

        out.close();

        System.out.print("Sucess, please …
Run Code Online (Sandbox Code Playgroud)

java arrays apache-poi

5
推荐指数
1
解决办法
80
查看次数

标签 统计

apache-poi ×1

arrays ×1

java ×1