apache-poi

How to read specific rows using Apache POI Event API?

爱⌒轻易说出口 提交于 2019-12-11 04:55:02
问题 I want to read large xls or xlsx file (about more than 30 MB and having 70,000+ rows). I was able to read small excel files using Apache POI eaily until I get an OutOfMemory error. Performance and memory usage is a concern for me. I read through many posts that if memory footprint is an issue, then for XSSF, you can get at the underlying XML data, and process it yourself using XSSF and SAX (Event API). Well, I found it interesting and now can read entire xlsx file without any issue. It

XSSF Excel Named Styles

扶醉桌前 提交于 2019-12-11 04:52:22
问题 I'm currently using the Apache POI library to generate excel files in Java. Here's what I'm wondering: In excel, it's possible to create new cell styles which will be added to the workbook. These styles are reusable and can be selected from the styles table. Using Apache POI, you can do something similar when constructing a workbook. You can create a new XSSFCellstyle, which is attached to the workbook, and can be applied to as many cells as you want. However, these styles are not reusable.

retain newline in word file generation using apache POI

心不动则不痛 提交于 2019-12-11 04:47:44
问题 I am trying to use apache POI to dynamically generate a word file by collecting some data in an arraylist and then printing it in the console output as well as the word file. I am able to get the output in console as well as the word file, but inside each arraylist element I have added a new line character at the end so that the array elements are printed linewise. In the console output the new line character works i.e. the arraylist elements come linewise but in the generated word file the

How to add hyperlink to Excel simple shape using apache poi?

梦想与她 提交于 2019-12-11 04:29:41
问题 I use Microsoft Excel 2007. I have a simple shape on the first excel sheet. I would like to add a hyperlink on this simple shape which refer to another sheet on the specific row and column. I make a research about this but I only found examples which demonstrate how to add a hyperlink to a given cell. How can I add a hyperlink to a given simple shape with the help of Apache POI? 回答1: I found solution of my issue. I hope it will help to someone else. // Example for hyperlink address // String

Apache POI for XSLX 3-color scale rule, How to define these method createConditionalFormattingRule() & class ConditionalFormattingThreshold.RangeType?

做~自己de王妃 提交于 2019-12-11 04:19:19
问题 This method createConditionalFormattingColorScaleRule() is not available in any of POI releases but explained in this link Conditional Formatting Color Scale Rule this interface ConditionalFormattingThreshold.RangeType is too unavailable in all POI releases but explained in this link Conditional Formatting Threshold Range Type Kindly suggest whether these method/interface need to be defined by developers themselves or they are still under apache POI development for future releases? Any help

Null pointer exception while using Apache POI

北慕城南 提交于 2019-12-11 04:15:55
问题 I am trying to write a excel file using Apache POI package. Here is the code snippet: String basePath = "/home/aman/Desktop"; String fileName = "result.xls"; File file = new File(basePath, fileName); //File not null. checked. OPCPackage pkg = OPCPackage.openOrCreate(file); //pkg not null. checked. Workbook wb = new XSSFWorkbook(pkg); //GenerateReport.java:63 I get the following error: Exception in thread "main" java.lang.NullPointerException at org.apache.poi.POIXMLDocumentPart.read

java.lang.OutOfMemoryError: Java heap space for 100000 records

倖福魔咒の 提交于 2019-12-11 03:59:29
问题 Trying to write an excel file using the following code public static void main(String[] args) { XSSFWorkbook workbook = new XSSFWorkbook(); XSSFSheet sheet = workbook.createSheet("Book Data"); Map<String, Object[]> data = new TreeMap<String, Object[]>(); data.put("1", new Object[] {"ID", "NAME", "LASTNAME"}); for(int i=2;i<100000;i++) { data.put(String.valueOf(i), new Object[] {i, "Name"+i, "LastName"+i}); } Set<String> keyset = data.keySet(); int rownum = 0; for (String key : keyset) { Row

Replace table column value in Apache POI

走远了吗. 提交于 2019-12-11 03:57:25
问题 I am using apache POI 3.7. I am trying to replace the value of a table column in a word document (docx). However, what I have done is it keeps appending the value of the current value in the document. But if a table column value is null, it places the value. Can you give me some thoughts how to resolve this. Below is the code I have done so far. Thanks in advance. package test.doc; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io

Apache POI, Excel 2007+ XML, and OSGI

喜欢而已 提交于 2019-12-11 03:42:27
问题 For a project I'm trying to get Excel XML functionality using Apache POI to work with OSGI. I've tried the POI ServiceMix bundle, but this was missing the ooxml-schemas jar. Adding the jar to the bundle and including it in the manifest didn't seem to work. Then I tried to creating wrapper bundles for POI 3.10, but also to no avail. Same error. Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl not found by org.apache.poi [8] at org.apache.felix

Efficient way to search records from an excel file using Apache-POI

爷,独闯天下 提交于 2019-12-11 03:34:37
问题 I am creating a web application which allows you to search some records from excel sheets.Excel sheets which need to be searched is a large one , it has 100k rows and 500 columns. What approach should be use for this? I just want to allow users to perform search on this excel sheet,SO should I use database for it(for it first I need to set excel sheet values in database)? Or Is there any other better approach than this? Does Apache POI provides any such direct method for searching excel files