apache-poi

Parse Excel by poi and target cell is empty sometimes parse ok sometimes throw nullpointexception

北城余情 提交于 2019-12-20 04:39:12
问题 I found a strange phenomenon of parse excel by poi. See code goods.subtitle = row.getCell(headerNameIndexMap.get("subtitle")).getStringCellValue(); parse subtitle column and set value to object. There are two excel, both subtitle column is empty, but parse one of them is ok, just subtitle property is null, but when parse another excel, it throws exception: java.lang.NullPointerException After copying some same name column from success excel to fail excel, before parse failed column could

Set path for Apache POI

我是研究僧i 提交于 2019-12-20 04:27:26
问题 I want to create excel file and write data in that file using java program. That is here and i extracted Apache POI in location where java file is present.and include that path in path variable. when i try to compile its giving following error: data.java:3: package org.apache.poi.hssf.usermodel does not exist import org.apache.poi.hssf.usermodel.HSSFCell; ^ data.java:4: package org.apache.poi.hssf.usermodel does not exist import org.apache.poi.hssf.usermodel.HSSFCellStyle; ^ data.java:5:

Unable to open excel using ApachePOI - Getting Exception

爱⌒轻易说出口 提交于 2019-12-20 04:24:40
问题 While trying to open an excel using ApachePOI I get org.apache.poi.openxml4j.exceptions.InvalidOperationException: Can't open the specified file: 'C:\Users\mdwaipay\AppData\Local\Temp\poifiles\poi-ooxml-1570030023.tmp' I checked. No such folder is being created. I am using Apache POI version 3.6. Any help? A similar code was running fine in a different workspace. At loss of thoughts here. Code: public Xls_Reader(String path) { this.path=path; try { fis = new FileInputStream(path); workbook =

Adding custom shapes to JTextpane and saved to new Word document

我与影子孤独终老i 提交于 2019-12-20 04:22:45
问题 If I load a Word document into a JTextPane , is there a way I could drop a custom shape in it, then save it as a new Word document? The results I'm looking for are just like dropping a shape anywhere onto the document using Insert-> Shapes in MS Word. 回答1: docx4all is a Swing-based docx editor. Like DocxEditorKit, it is built on top of docx4j. You'd need to extend it to support the functionality you are describing. 回答2: You can try to extend the DocxEditorKit http://java-sl.com/docx_editor

Generate Inter-Document Hyperlink with Apache POI in Java

﹥>﹥吖頭↗ 提交于 2019-12-20 03:57:10
问题 I'm generating an XWPFDocument with Apache POI (never used it before this) and I'd like to link one paragraph to another paragraph inside the same .docx document. Is this possible using POI's native functionality or do I need to deep-dive into XML Bean wrapper classes (i.e. CTP) to hand-jam this or am I out of luck? Every instance of a question regarding hyperlinks and POI that I have seen references creating either an external-type hyperlink or a link between Excel workbook sheets. I am as

Apache poi putting hyperlink in images

。_饼干妹妹 提交于 2019-12-20 03:53:13
问题 This is a Method I use for inserting images as icons in Excel: public void insertIcons(String URL, Sheet sheet, int colBegin, int colEnd, int rowBegin, int rowEnd) { try { InputStream iconInput = new FileInputStream(URL); byte[] byteTransf = IOUtils.toByteArray(iconInput); int pictureIdx = workbook.addPicture(byteTransf, org.apache.poi.ss.usermodel.Workbook.PICTURE_TYPE_PNG); iconInput.close(); CreationHelper helper = workbook.getCreationHelper(); Drawing drawingIcon = sheet

New line ignored in XSSFRichTextString

爱⌒轻易说出口 提交于 2019-12-20 03:52:38
问题 :EDIT START: Should anyone stumble across this q then here's a small heads up. After getting newLines to work I wanted to set the row height to match the content. To do this I simply set the row height to the number of newLines in the cellValue. However when creating a spreadsheet using poi it seems to be matter if you apply the cellStyle before or after the cellValue. In my case it only worked if I apply the cellStyle before adding the cellValue. Oh and remember that rowHeight is defined as

Get actual cell value of excel cell with POI without defining a datatype

倾然丶 夕夏残阳落幕 提交于 2019-12-20 03:39:46
问题 I catch my cells from an .xls file like this: cell.getStringCellValue(); But since some of the cells are numeric, I have to do this instead: try { cells[colIx] = cell.getStringCellValue(); } catch (IllegalStateException e) { cells[colIx] = String.valueOf(cell.getNumericCellValue()); } since it's getting a double and then converts it to a string this results in some unwanted operations like: 1 converts into 1.0 (not that kind of a big problem) 16711680 converts to 1.671168E7 How do I solve

Exception in thread “main” java.lang.IllegalAccessError: [duplicate]

不想你离开。 提交于 2019-12-20 03:26:20
问题 This question already has an answer here : Apache POI Parsing error (1 answer) Closed 4 years ago . I am getting the below Exception when I am trying to read an Excel file: Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.apache.poi.util.POILogger.log(ILjava/lang/Object;)V from class org.apache.poi.openxml4j.opc.PackageRelationshipCollection at org.apache.poi.openxml4j.opc.PackageRelationshipCollection.parseRelationshipsPart(PackageRelationshipCollection

How to get list of Named range,sheet name and referance formuls using XSSF and SAX (Event API) for large excel file

大城市里の小女人 提交于 2019-12-20 03:21:51
问题 I'm tring to to read large excel file (size~10MB,.xlsx) . I'm using below code Workbook xmlworkbook =WorkbookFactory.create(OPCPackage.openOrCreate(root_path_name_file)); But it's showing Heap memory issue. I have also seen other solution on StackOverflow some of them given to increase the JVM but i dont want to increase jvm. Issue 1) We can't use SXSSF (Streaming Usermodel API) because this is only for writing or creating new workbook. My sole objective to get the number of NamedRange of