apache-poi

POI : duplicate entry: org/apache/xmlbeans/xml/stream/Location.class

点点圈 提交于 2019-12-10 20:49:33
问题 Android POI integration. I have done lots of search but did not find solution. Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/xmlbeans/xml/stream/Location.class My gradle compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.google.code.gson:gson:2.4' compile 'com.jakewharton:butterknife:7.0.1' compile 'com.github

how to know whether a file is .docx or .doc format from Apache POI

风流意气都作罢 提交于 2019-12-10 19:38:37
问题 I know we can get it done by extension or by mime type, do we have any other way through which we can get the idea of type of file whether it is .docx or .doc. 回答1: If it is just a matter of decided whether a collection of files known to either be .doc or .docx but are not marked accordingly with an extension, you can use the fact that a .docx file is a zipped collection of files. Something to the tune as follows might help: boolean isZip = new ZipInputStream( fileStream ).getNextEntry() !=

apache poi XSSFClientAnchor not positioning picture with respect to dx1, dy1, dx2, dy2

China☆狼群 提交于 2019-12-10 19:16:17
问题 I am trying to add an image to excel using apach-poi version 3.16 . I am able to do that with HSSFWorkbook and XSSFWorkbook . But when i am trying to add spacing for the image i.e if I set dx1 , dy1 , dx2 , dy2 coordinates on XSSFClientAnchor it is not taking effect. Same thing is working on HSSFClientAnchor . I am attaching both classes and corresponding excel file generated. Could you please help me how can i do achieve the same result using XSSFClientAnchor . HSSF Class package poisamples;

Avoid formula injection, keeping cell value (quote prefix in HSSF/*.xls)

*爱你&永不变心* 提交于 2019-12-10 19:04:46
问题 The application I am working on creates Excel exports using Apache POI. It was brought to our attention, through a security audit, that cells containing malicious values can spawn arbitrary processes if the user is not careful enough. To reproduce , run the following: import java.io.FileOutputStream; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; public class

java.exe finished with non-zero exit value 1

谁说胖子不能爱 提交于 2019-12-10 17:55:58
问题 Just for start, I am not rly trying to read cell(s) from .xlsx file in Android, I already tried almost everything what I Googled, but every time (on two different PCs, both Java 1.7.0_79) when I'm trying to build (run) this app, it ends with same error: Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value

How to read cell value from formula cell using apache poi

爱⌒轻易说出口 提交于 2019-12-10 17:37:33
问题 I am trying to read all the data from a excel file, which also have some formula cell, but i have no idea that which cell is formula cell. how can i read all the values from the cells irrespective of the type of the cell. My code looks like this FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator(); while (rows.hasNext()) { row = (HSSFRow) rows.next(); Iterator cells = row.cellIterator(); while (cells.hasNext()) { cell = (HSSFCell) cells.next(); if (cell.getCellType() =

Maintaining hierarchy from XML to Excel file - Java

依然范特西╮ 提交于 2019-12-10 17:28:43
问题 I have an XML file containing nested records. I have to get records from the file and write to an Excel file. Right now, the file I have produced is a flat file. (I used Apache POI to write to the Excel file). I need it to maintain the hierarchical information, such that the nested records are indented. My XML file looks like: <node> <id>123</id> <label>ABC</label> <node> <id>456</id> <label>DEF</label> ....... so on My current Excel looks like : I need something like (representing the

Read integer from numeric cell using Apache POI in java

ぃ、小莉子 提交于 2019-12-10 17:13:09
问题 I have an application which reads xls sheet using apache poi. When the cell has numeric value, i read it by row.getCell(i).getNumericValue(). But it returns floating point digit. like if the cell value is 1, it returns 1.0. Can i convert it to int ? Any helpwould be appreciated. I tried Integer.parseInt(value)- but it throws NumberFormat exception.Any help is appreciated.Here is the pseudo code: FileInputStream file = new FileInputStream(new File("C:\\test.xls")); HSSFWorkbook workbook = new

Android - creating word document

爷,独闯天下 提交于 2019-12-10 16:56:52
问题 I want to create word (.doc) and excel (.xls) files on the android platform. For excel I am able to use jexel jar, but I am unable to find any API for word files. Can you tell me if there are any opensource/free API for writing word files on the android platform? People have suggested Apache-POI but I am not able to implement it in android. Please let me know if Apache-POI really works on android or not. 回答1: Look at this thread, its java generally but it should also work on android platform

Apache POI Excel workbook creation taking a long time

我们两清 提交于 2019-12-10 16:15:56
问题 I've noticed that the workbook creation statement for xlsx files with Apache POI v3.10 e.g. ` Workbook wb = WorkbookFactory.create(inputStream) or Workbook wb = new XSSFWorkbook(inputStream) ...is taking a long time (~30 seconds) and the file only has 72 rows with 10 columns (365KB). It's not a problem, but it just seems a bit excessive. I'm wondering if I'm doing anything wrong or not doing something I should be doing. Instantiation of an xls file with the same data (but only 25KB) only