apache-poi

opening excel ooxml 2007 xlsx document returns nullPointer exception

旧巷老猫 提交于 2019-12-24 01:44:59
问题 How do I open a 2007 xlsx ooxml file with Apache POI? I've added everything to my class path but keep getting this java.lang.NullPointerException error: "C:\Program Files\Java\jdk1.7.0_13\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:1804,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.7.0_13\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0_13\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.7.0_13\jre\lib\javaws.jar;C:\Program Files\Java\jdk1

Unable to read Excel using Apache POI

不羁的心 提交于 2019-12-24 01:43:28
问题 I'm reading excel using Apache POI but it keeps giving error for XSSFWorkbook class definition found error. I used different versions of Apache-poi jar libraries (i.e 4.1 , 4.0 and 3.12) none of them seem to fix this error. Here's a screenshot of libraries currently imported enter image description here Whats wrong inside the code ? try { File fileSrc = new File("C://Eclipse-Workspace//TestData//TestDataSet.xlsx"); FileInputStream fis = new FileInputStream(fileSrc); XSSFWorkbook workbook =

Reading blank cells of excel and returning List<List<String>>

微笑、不失礼 提交于 2019-12-24 00:58:39
问题 my excel file has 4 rows and 2 columns like with continuous values having 3row 1st column as blank value like given below phone plan ------------------ 85366667777 PLATINUM 85367890000 GOLD 85362524232 SILVER null SILVER 85362522436 DIAMOND public List<List<String>> readExcelFile(String fileName) { try { FileInputStream fileInputStream = new FileInputStream(fileName); POIFSFileSystem fsFileSystem = new POIFSFileSystem(fileInputStream); HSSFWorkbook workBook = new HSSFWorkbook(fsFileSystem);

R: rJava error with xlsx (0.4.2) package

怎甘沉沦 提交于 2019-12-24 00:09:39
问题 I am trying to use the xlsx package to fill a spreadsheet with information from an external file. Up until now, I have used addDataFrame() to put information into the spreadsheet, and everything about it that I have tried has been successful (fonts, colors, borders, etc.) The issue now is that I need to have a column of hyperlinks, and to do that I need to get or create the specific cells (I'm not sure which, and both give the same error). The following code: library(xlsx) wb = createWorkbook

Apache POI Focus on a particular cell in generated excel file

不羁岁月 提交于 2019-12-24 00:07:59
问题 Hi I am using apache poi to generate excel files. I am using XSSFWorkbook format. I am trying to make focus on the first cell of the generated excel file. I have tried the following code snippet. try { Sheet sheet = workbook.getSheetAt(0); workbook.setActiveSheet(0); Cell cell = sheet.getRow(0).getCell(0); cell.setAsActiveCell(); sheet.setActiveCell(cell.getAddress()); sheet.showInPane(0, 0); } catch (IllegalArgumentException e) { LOGGER.error("Failed to set active sheet and cell.", e); } I

How to create or update table of contents in a word file?

 ̄綄美尐妖づ 提交于 2019-12-23 22:21:46
问题 I can read or write word document in Java using Apache POI or docx4j. But I cant find any references to create or update table of contents in a Word file. Is there any other API can support TOC in Java? Or, is it possible in Apache POI or docx4j to have options to create or update TOC? 回答1: There's a cleaner way for this too. You just need to open a empty docx which will act as a template. Add some sample text into it with the style that you want to include and then this piece of code will

How to read xlsx file in an android application?

半城伤御伤魂 提交于 2019-12-23 18:28:13
问题 I know there's many same questions on stackoverflow, but it seems that I can't see any possible solution for reading the content of xlsx. What I have try: I have try to put the whole Apache POI library to an android application and try to read the xlsx file. However, the problem is that the Apache POI library is too heavy to put into an android application. An error message shows that the Dalvik VM cannot execute an app with more than 65536 methods. It there any way to read the content of the

decrypt excel files

允我心安 提交于 2019-12-23 17:53:08
问题 Hi I have 1000 encrypted workbooks which I would like to decrypt by providing a pwd. I could not find a decrypt method under apache poi or python's xlrd module. Does anyone know a library which could handle this ( wbc.decrypt(pwd) ). I would prefer a lib i could you use from a unix box. Thanks 回答1: Use the COM bindings to call the Unprotect method. import win32com.client excel = win32com.client.Dispatch('Excel.Application') workbook = excel.Workbooks.open(r'c:\mybook.xls', 'password')

Java: parsing ms-word document using POI/HWPF

笑着哭i 提交于 2019-12-23 17:05:26
问题 I have a ms-word document (MS-Office 2003; non-xml). Within this document there is a string associated with a bookmark. Furthermore, the word document contains word-macros. My goal is to read the document with java, replace the string associated with the bookmark, and save the document back to word format. My first approach was using Apache POI HWPF: HWPFDocument doc = new HWPFDocument(new FileInputStream("Test.doc")); doc.write(new FileOutputStream("Test_generated.doc")); The problem with

Meaning and unit of `x` and `y` in Office Open XML `wrapPolygon`

百般思念 提交于 2019-12-23 16:47:37
问题 Does someone knows what is the meaning and unit of x and y in Office Open XML wrapPolygon ? The documentation states: "Specifies a coordinate on the x-axis. The origin point for this coordinate shall be specified by the parent XML element. ...The possible values for this attribute are defined by the ST_Coordinate simple type (§ 5.1.12.16)." That sounds like it should be describing a polygon starting at x =0 and y =0 in top left point of the picture. And the unit would be EMU . But this cannot