在Apache POI XWPFDocument(Word)中,我使用此代码将用户定义的格式MyHeadline
分配给新段落。 MyHeadline
包含在通过LibreOffice创建的template.docx
中。
XWPFDocument document = new XWPFDocument(new FileInputStream("template.docx"));
XWPFParagraph paragraph = document.createParagraph();
paragraph.setStyle("MyHeadline");
我的问题:使用Apache POI XSSFWorkbook(Excel)是否有类似的方法?
故障代码!
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!