使用apache-poi在xls文件中填充单元格

时间:2013-08-13 08:25:35

标签: java cell fill hssf

为什么它不起作用?我使用setFillForegroundColor并清除单元格,而不是用颜色(石灰)填充它。

//Get the workbook instance for XLS file
HSSFWorkbook workbook = new HSSFWorkbook(file);
CreationHelper createHelper = workbook.getCreationHelper();
//Get first sheet from the workbook
HSSFSheet sheet = workbook.getSheetAt(0);
CellStyle style = workbook.createCellStyle();
style.setFillForegroundColor(IndexedColors.LIME.getIndex());
    ......
                label1:
                for (int i=0;i<ListOfList.size();i++)                      {
                    Row row = sheet.getRow(i);
                    for (int j=0;j<ListOfList.get(i).size();j++) {

                        for (int k=0;k<List.size();k++){
                            if (List.get(k).equals(ListOfList.get(i).get(j)) | ListOfList.get(i).get(j).contains(List.get(k))) {
                                System.out.println("("+List.get(k)+") ASU <--> ("+ListOfList.get(i).get(j)+") RZS "+"Строчка: "+i+" Столбец: "+j);
                                row.createCell(2+j).setCellStyle(style);
                            }
                            else {}
                        }
                                                                 }
                                                                             }

0 个答案:

没有答案