In an Apache POI XWPFDocument (Word) I use this code to assign the user defined format MyHeadline
to a new paragraph. MyHeadline
is contained in template.docx
which was created with LibreOffice.
XWPFDocument document = new XWPFDocument(new FileInputStream("template.docx"));
XWPFParagraph paragraph = document.createParagraph();
paragraph.setStyle("MyHeadline");
My question: Is there a similar way to do this with an Apache POI XSSFWorkbook (Excel)?
Malfunctioning code!
XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream("template.xlsx"));
XSSFSheet sheet = workbook.getSheetAt(0);
XSSFRow row = sheet.createRow(0);
XSSFCell cell = row.createCell(0);
cell.setCellValue("Brennholzverleih");
cell.setCellStyle("MyCellStyle"); // This is what I want to do. "MyCellStyle" is an
// user defined cell format contained in "template.xlsx".
// Of course there is no setCellStyle(String) method!