I've tried setting the default height, and I've tried setting the height of the rows itself, as that was what I saw in the xml of the file I made by hand, but neither seems to have any effect.
- Code: Select all
SpreadsheetMLPackage pkg = SpreadsheetMLPackage.createPackage();
WorksheetPart sheet = pkg.createWorksheetPart(new PartName("/sheet1.xml"), "Sheet1", 1);
CTSheetFormatPr format = Context.getsmlObjectFactory().createCTSheetFormatPr();
format.setDefaultRowHeight(16.8);
format.setCustomHeight(Boolean.TRUE);
sheet.getJaxbElement().setSheetFormatPr(format);
SheetData sheetData = sheet.getJaxbElement().getSheetData();
Row row = Context.getsmlObjectFactory().createRow();
row.setHt(16.8);
row.setCustomHeight(Boolean.TRUE);
row.setR(1L);
Cell cell1 = Context.getsmlObjectFactory().createCell();
cell1.setV("1234");
row.getC().add(cell1);
Cell cell2 = Context.getsmlObjectFactory().createCell();
cell2.setV("56");
row.getC().add(cell2);
sheetData.getRow().add(row);
SaveToZipFile saver = new SaveToZipFile(pkg);
saver.save("C:\\sheet10.xlsx");