apache-poi

setCellType(HSSFCELL.CELL_TYPE_NUMERIC) is not working in apache poi

半世苍凉 提交于 2019-12-12 21:09:08
问题 SetCellType(HSSFCELL.CELL_TYPE_NUMERIC) is not working in apache poi. Anyone have used this feature of POI in JAVA? When I created XLS file using POI and cell contains integer value and I set cell type as numeric at that time that cell reflects some other integer value. Example: Using JAVA program and poi utility, I am putting in Cell A1 value "5" . Now this cell contains Integer value but by default cell type is CELL_TYPE_STRING . So this cell gives me error and asked me to convert this cell

Can't change row text in .docx file once row is added to table

走远了吗. 提交于 2019-12-12 20:19:44
问题 I have the problem with the following code: XWPFTable table = <get table somehow>; CTRow firstRow = table.getRow(0).getCtRow(); for (int i = 0; i < data.getRowCount(); i++) { CTRow ctRow = (CTRow) firstRow.copy(); XWPFTableRow row = new XWPFTableRow(ctRow, table); XWPFRun[] cellRuns = row.getTableCells() .stream() .map(c -> c.getParagraphs().get(0)) .map(p -> p.getRuns().isEmpty() ? p.createRun() : p.getRuns().get(0)) .toArray(XWPFRun[]::new); for (int j = 0; j < cellRuns.length; j++) {

How to determine if a Zip Bomb error thrown when retrieving an Excel files Styles Table is legitimate?

余生长醉 提交于 2019-12-12 18:58:57
问题 I've got a piece of code which is erroring when I attempt to get the Styles Table for an Excel file, using apache POIs XSSFReader. All I do, involving the file, is shown below: XSSFReader reader = new XSSFReader(OPCPackage.open(excelFile.getPath(), PackageAccess.READ)); StylesTable table = reader.getStylesTable(); I get the following error: Caused by: java.io.IOException: Zip bomb detected! The file would exceed certain limits which usually indicate that the file is used to inflate memory

How to show dropdown in excel using jrxml (jasper api)?

故事扮演 提交于 2019-12-12 18:43:20
问题 I am new to jasper . My project used jasper to create an excel template that has only column names (eg : Name , Age , Department , Location) which uses jrxml for fonts and alignment. [basically we used the for showing the column names] User can download the template and they can enter the values they want. Now in order to avoid user enter the details manually by entering values , I would like to give dropdowns in the template with some hard coded values . For example for the field 'Location'

How to add header column in excel using Java Apache POI?

故事扮演 提交于 2019-12-12 17:04:24
问题 I am writing a java program in which I have to take data from XML file and put it into excel file. While doing this I have to create row headers and add data accordingly. I know how to create column headers. I can do it in following way: .... HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("EDR Raw Data"); Row header = sheet.createRow(0); header.createCell(0).setCellValue("Header1"); header.createCell(1).setCellValue("Header2"); header.createCell(2)

Reading Excel checkbox values in Java Apache POI

亡梦爱人 提交于 2019-12-12 16:55:23
问题 I have spent countless hours trying to find a solution to this. I have tried Apache POI, JExcel and JXLS but no where have I found code to successfully read checkbox (form control) values. If anyone has found a working solution then it would be great if you could share it here. Thanks! UPDATE I have written code that reads the checkbox but it cannot determine whether it is checked or not. import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io

Error: How to read empty cell in Excel

╄→尐↘猪︶ㄣ 提交于 2019-12-12 15:55:22
问题 I'm trying to read data from excel using POI. How can I check if that is an empty cell? I don't know what is missing I think this should be working: java.util.Iterator<Row> rows = worksheet.rowIterator(); HSSFRow row = (HSSFRow) rows.next(); HSSFCell cellF1 = (HSSFCell) row.getCell(5); if(cellF1.getCellType() == HSSFCell.CELL_TYPE_BLANK) { String val = ""; } I got error in if statement (null pointer), but only if I use this I can check that: while (rows.hasNext()) { HSSFRow row = (HSSFRow)

Apply POI Custom color using 'Hexadecimal Color Codes' provided

怎甘沉沦 提交于 2019-12-12 15:12:46
问题 I am currently using HSSFColor/HSSFPalette and XSSFColor to set the Existing/Custom Colors. Implementation is as follows : for e.g. font.setColor(HSSFColor.WHITE.index); for HSSF or cs.setFillForegroundColor(xssfColor); for XSSF I want to pass parameters in both the above cases for "Hexadecimal Color Codes". Like : for HSSF: font.setColor()/font.setColor(getShortIndexFromHexColorCodes()) for XSSF: cs.setFillForegroundColor(); Is there any way out to do the above thing, where I can pass

How to get “last saved by” Office file attribute in Java

我怕爱的太早我们不能终老 提交于 2019-12-12 14:55:43
问题 I am trying to get the "last saved by" attribute from MS Office 2013 file(docx, xlsx, pptx ...). I am using Apache POI, but I can get only the Author of the file with the following code: OPCPackage pkg = OPCPackage.open(file); POIXMLProperties props = new POIXMLProperties(pkg); props.getCoreProperties().getCreator(); Is there a way to get "last saved by" attribute? 回答1: Lookin at the Apache POI OOXML Properties Extractor as a good source of inspiration for this sort of problem, we see what

Exception in thread “AWT-EventQueue-0” java.lang.NoClassDefFoundError

情到浓时终转凉″ 提交于 2019-12-12 13:38:10
问题 I am trying to read a .docx file into a JTextPane , but its giving some exception. I am using POI library. What should I do? Help me out, please. Here is my code: file = new File( "C:\\Users\\Siddique Ansari\\Documents\\CV Parser\\Siddique_Resume.docx"); FileInputStream fis=new FileInputStream(file.getAbsolutePath()); XWPFDocument document=new XWPFDocument(fis);// line no 549 extractor = new XWPFWordExtractor(document); String fileData = extractor.getText(); Document doc = jTextPane1