apache-poi

Socket Exception while generating bulk excel file using Apache Poi

故事扮演 提交于 2019-12-11 08:16:19
问题 I am getting SocketConnectionException while generating Excel file for bulk data (more than 0.5 million records). The code of my web application writes to `outputstream. Here's a snippet of code: while (sr.next()) { counter++; //advance counter view = (DataClass) sr.get(0); try { //writing fields values for Activity Report file reportService.writeExcelFieldsValue(rowCounter,sheet,view,user,exportedFields); rowCounter++; } catch (Exception e) { throw new RuntimeException(e); } if (counter ==

How to include POI library into an Android project?

╄→尐↘猪︶ㄣ 提交于 2019-12-11 08:11:15
问题 How to include the poi library into an android project? When I want to include it in the regular Java project, I would right click on the project, in Eclipse -> Build path -> Add external Archives How am I supposed to do it in an Android project? 回答1: You should put jar in libs folder and then Project -> Properies -> Java Buid Path -> Add JARs -> Select jar of your library from libs folder -> OK. 回答2: You should put jar in libs folder (the same level as res or src folder) and do Eclipse ->

How to increase width of column of table in word file by JAVA

自古美人都是妖i 提交于 2019-12-11 07:55:49
问题 I working on a small project where I am creating word file by Java and enter some detail in this word file. I am able to create word file and also able to enter data into it. I also write a table into word file and enter some details. Now what I want, I want to increase width of specific column. Is there any way to do this? I am using Apache POI drivers for creating word file and writing data into it. I am using below code: XWPFDocument document= new XWPFDocument(); try{ FileOutputStream out

Poi: Saving an excel file as xlsx after opening it from xlsm

不羁岁月 提交于 2019-12-11 07:54:44
问题 I'm writing a java program that opens a user-defined excel file, fills it with data, and then saves it under a user-specified path, file name and extension. It should be, but isn't, possible to declare the output to be saved as xlsx, even though the input file was xlsm. If I try that with the code as below, opening the file gives me the error: The file 'FileName.xlsx' is a macro-free file, but contains macro-enabled content Key segments of code: Opening the workbook: try (Workbook workbook =

Heap error while writing xls file with Apache POI

大兔子大兔子 提交于 2019-12-11 07:39:55
问题 I am using Apache POI to create an excel[.xls] file. Now an excel can have 65535 rows & 256 cols. I am trying to write the java code to write the xls file with 65535x256 cells. I am getting a heap error. The current heap conf is -Xms512m -Xmx1700m. RAM size is 3.5gb. What is the way out for me ? I am using HSSF* classes to write xls file. Stack Trace is (I have enabled the -verbose:gc option) [Full GC [Tenured: 1092288K->1092288K(1092288K), 3.3174494 secs] 1583807K->1583807K(1583808K), [Perm

Java Apache POI : Read / Write from .doc file issue

瘦欲@ 提交于 2019-12-11 07:39:19
问题 I am writing a code to read a .doc file as a template and write data in new .doc file after various iterations. My code seems to have some simple issue that I am not able to figure out. Below is the code I have written, [I got basic skeleton somewhere on stackoverflow only.] public class HWPFTest { public static void main(String[] args) { String inputFile = "F:\\docx\\input.doc"; String outputFile = "F:\\docx\\output.doc"; POIFSFileSystem fs = null; try { for (int i = 0; i < 3; i++) { fs =

XSSFCell in Apache POI encodes certain character sequences as unicode character

最后都变了- 提交于 2019-12-11 07:35:37
问题 XSSFCell seems to encode certain character sequences as unicode characters. How can I prevent this? Do I need to apply some kind of character escaping? e.g. cell.setCellValue("LUS_BO_WP_x24B8_AI"); // The cell value now is „LUS_BO_WPⒸAI" In Unicode Ⓒ is U+24B8 I've already tried setting an ANSI font and setting the cell type to string. 回答1: This character conversion is done in XSSFRichTextString.utfDecode() I have now written a function that basicaly does the same thing in reverse. private

Missing mandatory unique key field error in SolrJ

廉价感情. 提交于 2019-12-11 07:33:27
问题 I've this issue in my project. I read my .xlsx excel file using Apache Poi and I want to index them in my Solr core. I use SolrInputDocument to index reading file. Here is my java codes package org.solr; import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import java.io.File; import java.io

How to apply bold text style for a range of text inside a cell using Apache POI?

谁说胖子不能爱 提交于 2019-12-11 06:58:13
问题 How to make a range of text bold text style using Apache POI? Eg: Instead of applying style for the entire cell. I used to do this in vb.net with these lines of code: excellSheet.Range("C2").Value = "Priority: " + priority excellSheet.Range("C2").Characters(0, 8).Font.Bold = True But I can't find the way to do that in Java using Apache POI. Any help will be much appreciated. Thanks! 回答1: First, create your Font with bold styling, using the Workbook object. Font font = workbook.createFont();

Apache POI: How can I set the pivot table display layout?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 06:47:36
问题 I have tried use the poi to generator excel and build a pivot table in. like the code following. this is not i want to get. you can see in the result. only month have a filter icon. but when you select a cell in the pivot table then select the design tab. choose the 'Report Layout' then change to show in outline form the filter will apply to month,group1 and code. is there any way to use the poi to do the step I described before? import org.apache.poi.ss.SpreadsheetVersion; import org.apache