Excel Apache POI打印问题

我正在使用Apache POI来生成dynamicExcel。

我有彩色细胞。 对于我使用的颜色

headerCellStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); headerCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);

Excel生成完美的颜色,但是当我打印这个Excel背景颜色来与虚线的阴影。

我试过并检查以下内容:

  1. 它不是打印机问题
  2. 当我将生成的Excel的内容复制到新的Excel中。 它的印刷来完美。

所以在代码或POI中一定有错误。

如果excel生成正确,那么我不认为这是一个Apache poi /代码的问题。

我正在粘贴Apache poi官方页面的例子。

如果有问题,请检查并validation您的代码:::

Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet("new sheet"); // Create a row and put some cells in it. Rows are 0 based. Row row = sheet.createRow((short) 1); // Aqua background CellStyle style = wb.createCellStyle(); style.setFillBackgroundColor(IndexedColors.AQUA.getIndex()); style.setFillPattern(CellStyle.BIG_SPOTS); Cell cell = row.createCell((short) 1); cell.setCellValue("X"); cell.setCellStyle(style); // Orange "foreground", foreground being the fill foreground not the font color. style = wb.createCellStyle(); style.setFillForegroundColor(IndexedColors.ORANGE.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); cell = row.createCell((short) 2); cell.setCellValue("X"); cell.setCellStyle(style); // Write the output to a file FileOutputStream fileOut = new FileOutputStream("workbook.xls"); wb.write(fileOut); fileOut.close();