apache-poi

SUM(ABOVE) functionality in apache poi or docx4j

こ雲淡風輕ζ 提交于 2020-05-17 06:05:49
问题 I am trying to implement =SUM(ABOVE) function in docx which is used to sum all elements above to tht column. I was able to implement this with apache poi using : CTSimpleField sumAbove = paragraphInCell.getCTP().addNewFldSimple(); sumAbove.setInstr("=SUM(ABOVE)"); //set sum field dirty, so it must be calculated while opening the document sumAbove.setDirty(STOnOff.TRUE); This is ok when someone opens the document and it calculates it. But if I need to convert the document without opening it to

SUM(ABOVE) functionality in apache poi or docx4j

一曲冷凌霜 提交于 2020-05-17 06:04:24
问题 I am trying to implement =SUM(ABOVE) function in docx which is used to sum all elements above to tht column. I was able to implement this with apache poi using : CTSimpleField sumAbove = paragraphInCell.getCTP().addNewFldSimple(); sumAbove.setInstr("=SUM(ABOVE)"); //set sum field dirty, so it must be calculated while opening the document sumAbove.setDirty(STOnOff.TRUE); This is ok when someone opens the document and it calculates it. But if I need to convert the document without opening it to

Convert word to pdf java

我与影子孤独终老i 提交于 2020-05-14 12:06:48
问题 I'm trying convert word to pdf, my code is: public static void main(String[] args) { try { XWPFDocument document = new XWPFDocument(); document.createStyles(); XWPFParagraph paragraph = document.createParagraph(); XWPFRun title = paragraph.createRun(); title.setText("gLETS GO"); PdfOptions options = PdfOptions.create(); OutputStream out = new FileOutputStream(new File("C:/Users/pepe/Desktop/DocxToPdf1.pdf")); PdfConverter.getInstance().convert(document, out, options); System.out.println("Done

How to set fixed column width in Apache POI

巧了我就是萌 提交于 2020-05-11 06:54:06
问题 How to set fixed column width in Apache POI. I want to make my first column to fixed width. I have tried with sheet.setColumnWidth(0, 1000); cellStyle.setWrapText(true); //Set wordwrap it is not reflecting public XSSFWorkbook generateReport(List<Dto> result, boolean isRes, boolean isRes1) { XSSFWorkbook workbook = null; XSSFSheet sheet = null; XSSFRow row = null; XSSFCell cell = null; String[] headers = null; int rowNum = 0; int colNum = 0; CellStyle cellStyle = null; CellStyle headerStyle =

How to set fixed column width in Apache POI

微笑、不失礼 提交于 2020-05-11 06:53:14
问题 How to set fixed column width in Apache POI. I want to make my first column to fixed width. I have tried with sheet.setColumnWidth(0, 1000); cellStyle.setWrapText(true); //Set wordwrap it is not reflecting public XSSFWorkbook generateReport(List<Dto> result, boolean isRes, boolean isRes1) { XSSFWorkbook workbook = null; XSSFSheet sheet = null; XSSFRow row = null; XSSFCell cell = null; String[] headers = null; int rowNum = 0; int colNum = 0; CellStyle cellStyle = null; CellStyle headerStyle =

JavaFx: Export TableView to excel with name of columns

拈花ヽ惹草 提交于 2020-05-11 01:58:35
问题 I'm trying to export tableView to excel using Apache POI Every thing is well but I need export all my table not just items, I mean with columns names when I use this code: HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet spreadsheet = workbook.createSheet("sample"); HSSFRow row = null; for (int i = 0; i < TousEmpSusp.getItems().size(); i++) { row = spreadsheet.createRow(i); for (int j = 0; j < TousEmpSusp.getColumns().size(); j++) { row.createCell(j).setCellValue(TousEmpSusp.getColumns()

JavaFx: Export TableView to excel with name of columns

白昼怎懂夜的黑 提交于 2020-05-11 01:55:48
问题 I'm trying to export tableView to excel using Apache POI Every thing is well but I need export all my table not just items, I mean with columns names when I use this code: HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet spreadsheet = workbook.createSheet("sample"); HSSFRow row = null; for (int i = 0; i < TousEmpSusp.getItems().size(); i++) { row = spreadsheet.createRow(i); for (int j = 0; j < TousEmpSusp.getColumns().size(); j++) { row.createCell(j).setCellValue(TousEmpSusp.getColumns()

Reading from an Excel (xlsx) file using Apache POI library throws NullPointerException

Deadly 提交于 2020-04-18 12:33:43
问题 I 'm building a JSP web application using Eclipse IDE. The web application loads without issue on tomcat server ver 7. We got a new requirement to read from xls and xlsx file. So we have used Apache POI library (4.1.2) to implement this as follows: I have taken out other codes as they are not relevant for this post FileInputStream file = new FileInputStream(new File(args[0])); //Create Workbook instance holding reference to .xlsx file XSSFWorkbook workbook = new XSSFWorkbook(file); //<- This

Hi, how can I restart numbering in java word apache poi?

ε祈祈猫儿з 提交于 2020-04-18 03:48:49
问题 The method below adds numbering successfully, however when I try to add numbering to other sections which are supposed to start from zero, the numbering added in the first list continues on my second list. How do I restart it? public void numbering(XWPFDocument document) { List<XWPFParagraph> list = document.getParagraphs(); CTAbstractNum cTAbstractNum = CTAbstractNum.Factory.newInstance(); CTLvl cTLvl = cTAbstractNum.addNewLvl(); cTLvl.addNewNumFmt().setVal(STNumberFormat.DECIMAL); cTLvl

Hi, how can I restart numbering in java word apache poi?

那年仲夏 提交于 2020-04-18 03:48:47
问题 The method below adds numbering successfully, however when I try to add numbering to other sections which are supposed to start from zero, the numbering added in the first list continues on my second list. How do I restart it? public void numbering(XWPFDocument document) { List<XWPFParagraph> list = document.getParagraphs(); CTAbstractNum cTAbstractNum = CTAbstractNum.Factory.newInstance(); CTLvl cTLvl = cTAbstractNum.addNewLvl(); cTLvl.addNewNumFmt().setVal(STNumberFormat.DECIMAL); cTLvl