我是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 check the file");
} catch (Exception e) {
e.printStackTrace();
}
}
我得到的错误是:
参数类型Cell中的方法setCellValue(double)不适用于参数(String [])
请帮我解决这个阵列问题.
最佳答案
原文链接:https://www.f2er.com/java/437513.html