L
L
LS Timer2017-09-26 14:43:49
Java
LS Timer, 2017-09-26 14:43:49

Report in excel using "apache poi"?

Essence:
When you click on the button, an excel document is downloaded.
It has merged cells that should have their borders painted over
. Problem:
only half of the cell is painted over. The part that was before the merging of two cells

spoiler
HSSFRow row3 = spreadsheet.createRow(rowid++);
 spreadsheet.addMergedRegion(new CellRangeAddress(rowid - 1, rowid, 0, 0));
        cell = row3.createCell(0);
        cell.setCellValue("№");
        cell.setCellStyle(styleCaption);

spoiler
HSSFCellStyle styleCaption = workbook.createCellStyle();
        styleCaption.setAlignment(HSSFCellStyle.ALIGN_CENTER);
        styleCaption.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
        styleCaption.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        styleCaption.setBorderLeft(HSSFCellStyle.BORDER_THIN);
        styleCaption.setBorderRight(HSSFCellStyle.BORDER_THIN);
        styleCaption.setBorderTop(HSSFCellStyle.BORDER_THIN);
        styleCaption.setFillBackgroundColor(HSSFColor.GREY_50_PERCENT.index);
        styleCaption.setFont(font);
        styleCaption.setWrapText(true);
        styleMap.put("styleCaption", styleCaption);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LS Timer, 2017-10-26
@light___soul

Sergey Gornostaev @TheDeadOne
Get all the regions of the merged cells, when assigning a style to a cell, check if it exists in any of the regions, if it is included in the region, apply the style to all cells of this region.
After merging the cells, you need to manually paint over a non-main cell.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question