Whoops. I missed a line of code. I expect that all 4 cells are bold. I'll test this out later today to see what's up.
On Oct 18, 2017 06:34, "Javen O'Neal" <[email protected]> wrote: > Reading your code, I would expect foo, bar, and baz would be bold and bat > should not be bold. Are you getting the opposite of this? > > On Oct 18, 2017 05:39, "Alexander Hörnlein" <alexander.hoernlein@uni- > wuerzburg.de> wrote: > > > Hi all, > > this is my "minimal" code: > > final Workbook wb = new XSSFWorkbook(); > final Sheet s = wb.createSheet(); > final Row r = s.createRow(0); > final Cell c1 = r.createCell(0); > c1.setCellValue("foo"); > final Cell c2 = r.createCell(1); > c2.setCellValue("bar"); > final Cell c3 = r.createCell(2); > c3.setCellValue("baz"); > final Cell c4 = r.createCell(3); > c4.setCellValue("bat"); > final Font f = wb.createFont(); > f.setBold(true); > {// 1 > final Map<String, Object> props = new HashMap<>(); > props.put(CellUtil.ALIGNMENT, HorizontalAlignment.RIGHT); > props.put(CellUtil.BORDER_BOTTOM, BorderStyle.DOUBLE); > props.put(CellUtil.FONT, f); > CellUtil.setCellStyleProperties(c1, props); > } > { // 2 > CellUtil.setCellStyleProperty(c2, CellUtil.ALIGNMENT, > HorizontalAlignment.RIGHT); > CellUtil.setCellStyleProperty(c2, CellUtil.BORDER_BOTTOM, > BorderStyle.DOUBLE); > CellUtil.setCellStyleProperty(c2, CellUtil.FONT, f); > } > { // 3 > final CellStyle cs = wb.createCellStyle(); > cs.setAlignment(HorizontalAlignment.RIGHT); > cs.setBorderBottom(BorderStyle.DOUBLE); > cs.setFont(f); > c3.setCellStyle(cs); > } > { // 4 > { > final Map<String, Object> props = new HashMap<>(); > props.put(CellUtil.ALIGNMENT, HorizontalAlignment.RIGHT); > CellUtil.setCellStyleProperties(c4, props); > } > { > final Map<String, Object> props = new HashMap<>(); > props.put(CellUtil.BORDER_BOTTOM, BorderStyle.DOUBLE); > CellUtil.setCellStyleProperties(c4, props); > } > { > final Map<String, Object> props = new HashMap<>(); > props.put(CellUtil.FONT, f); > CellUtil.setCellStyleProperties(c4, props); > } > } > final OutputStream os = new FileOutputStream(new > File("D:\\_scratch\\exceloutput_test\\res_" + System.currentTimeMillis() > + ".xlsx")); > wb.write(os); > os.close(); > wb.close(); > > In 1 one (bis) setCellStyleProperties is used, in 2 three > setCellStyleProperty calls are used, in 3 a CellStyle is created and in 4 > each part of the style is set with one setCellStyleProperties. > > What I /should/ get: All cells are right aligned with border on top and > bold. > > What I get is foo, bar, baz, bat are right aligned with a border on top, > but only baz is bold. > > POI 3.17 is used. > > Is this a bug or am I doing something wrong here? > > cheers > Alexander > > >
