[英]Excel Apache POI Printing Issue
I am using Apache POI to generate Dynamic Excel. 我正在使用Apache POI生成动态Excel。
I have colored cells. 我有彩色细胞。 For color i am using
对于我正在使用的颜色
headerCellStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
headerCellStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); headerCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
headerCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
Excel generated with perfect colors but when i print this excel background color come with dotted shade. 用完美的颜色生成的Excel但是当我打印这个excel背景颜色时带有点缀的阴影。
I tried and checked the following: 我试过并检查了以下内容:
So there must be something wrong in code or in POI. 所以在代码或POI中一定有问题。
If excel is generated correctly then i don't think it is an issue of Apache poi/code. 如果正确生成excel,那么我认为它不是Apache poi /代码的问题。
I am pasting the example from official page of Apache poi. 我从Apache poi的官方页面粘贴了这个例子。
Please check and verify your code if there is some issue::: 如果有问题,请检查并验证您的代码:::
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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.