Mridul
Mridul

Reputation: 1

Excel Apache POI Printing Issue

I am using Apache POI to generate Dynamic Excel.

I have colored cells. For color i am using

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

Excel generated with perfect colors but when i print this excel background color come with dotted shade.

I tried and checked the following:

  1. Its not a printer issue
  2. When I copy content of generated excel into new excel. Its print comes perfect.

So there must be something wrong in code or in POI.

Upvotes: 0

Views: 1019

Answers (1)

dev
dev

Reputation: 715

If excel is generated correctly then i don't think it is an issue of Apache poi/code.

I am pasting the example from official page of 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();

Upvotes: 2

Related Questions