bucle datos de la matriz usando Apache poi

Sharky:

Soy un principiante en java y Apache POI.

Así que ahora lo que quiero lograr es que quiero rizar el día de matriz fila por fila (vertical) en la columna Días:

Días festivos Fecha Clase

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 check the file");

    } catch (Exception e) {
        e.printStackTrace();
    }

}

El error que estoy recibiendo es que:

El setCellValue método (doble) en la celda de tipo no es aplicable para los argumentos (String [])

Por favor me ayude a resolver este problema matriz.

Jim Garrison:
The method setCellValue(double) in the type Cell is not applicable for the arguments (String[])

Se ha intentado pasar una matriz de cadenas declarado como

String[] days = { "SU", "MO",...};

al setCellValue()método. No hay está sobrecargado variante de setCellValue()que acepta un String[]argumento. Creo que quería decir

cell.setCellValue(days[i-1]);

El mensaje de error es un poco confuso porque en tratar de resolver el método que eligió uno (el que toma double) para indicar en el mensaje.

Supongo que te gusta

Origin http://43.154.161.224:23101/article/api/json?id=181861&siteId=1
Recomendado
Clasificación