apache-poi

Insert image in column to excel using Apache POI

空扰寡人 提交于 2019-12-22 10:03:52
问题 I'm trying to insert an image into a cell in excel. I've added pictures fine, but I still runs anywhere. I want to say that I want this column. 回答1: You can set the row and column first then set the image. try { Workbook workbook = new XSSFWorkbook(); Sheet sheet = workbook.createSheet("MYSheet"); InputStream inputStream = new FileInputStream("path_to_image.jpg"); byte[] imageBytes = IOUtils.toByteArray(inputStream); int pictureureIdx = workbook.addPicture(imageBytes, Workbook.PICTURE_TYPE

POI: Unexpected record type org.apache.poi.hssf.record.HyperlinkRecord

僤鯓⒐⒋嵵緔 提交于 2019-12-22 09:57:02
问题 I am working on a simple task: Reading an Excel file and converting it to an object. Though, I am facing a problem in reading the Excel file (.xls) I will receive it from an external system (maybe they autogenerated it). If I open it and just do a simple save (with or without changing anything in the Excel file), my parser logic works fine. But if I don't edit and save the file and try to parse the original file as is, I get an exception at this line while loading the .xls file: HSSFWorkbook

How can I get footnotes and paragraphs from Apache POI?

倾然丶 夕夏残阳落幕 提交于 2019-12-22 09:48:32
问题 I have code to get paragraphs from a .doc file in Apache POI, but I'd like to get footnotes also. Also, is this the only way to get paragraphs? Code so far: InputStream stream = ... HWPFDocument document = new HWPFDocument(stream); Range range = document.getRange(); StyleSheet stylesheet = document.getStyleSheet(); for (int i = 0; i < range.numParagraphs(); i++) { Paragraph paragraph = range.getParagraph(i); String text = paragraph.text(); } Any ideas? 回答1: You could try this... WordExtractor

Remove template row in JXLS when input list is empty

痴心易碎 提交于 2019-12-22 09:48:21
问题 I'm using JXLS to populate a template excel spreadsheet. Sometimes, one input - a list - is empty. When this happens, the template fields which use this list are shown in the populated spreadsheet in full JXLS regalia - eg, " ${someList.someValue} ". The fields in question are all in a single row (expanded to list.size() rows by JXLS). I want to clear the whole row when there are no records in the list. Is there a way to do so in JXLS? Alternatively, can anyone suggest a complementary way to

generate excel in java

 ̄綄美尐妖づ 提交于 2019-12-22 09:45:51
问题 I want to generate excel with enabling auto-filter option.For that I have create one template excel file by enabling auto-filter option but when I write something into that template excel file auto-filter option disabled again. Is there any solution to create excel file by enabling auto-filter option. 回答1: Not sure if this is what you are looking for (and you don't really describe how you write the file today). "create excel file by enabling auto-filter option" doesn't really make sense to me

Java Apache-poi, memory leak with excel files

纵然是瞬间 提交于 2019-12-22 09:28:48
问题 I need to read (15000) excel files for my thesis. I'm using apache poi to open and later to analyze them but after around 5000 files I'm getting the following exception and stacktrace: Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded at org.apache.xmlbeans.impl.store.Cur$CurLoadContext.attr(Cur.java:3044) at org.apache.xmlbeans.impl.store.Cur$CurLoadContext.attr(Cur.java:3065) at org.apache.xmlbeans.impl.store.Locale$SaxHandler.startElement(Locale.java:3263)

How to lazily read big Excel 2007 files with Apache POI

末鹿安然 提交于 2019-12-22 09:18:22
问题 I'd like to read a big Excel 2007 file with Apache POI. Quick start guide states that a File should be used to conserve memory. When opening a workbook, either a .xls HSSFWorkbook, or a .xlsx XSSFWorkbook, the Workbook can be loaded from either a File or an InputStream. Using a File object allows for lower memory consumption, while an InputStream requires more memory as it has to buffer the whole file. I therefore wrote approximately this: opcPackage = OPCPackage.open(file); XSSFWorkbook

Embed document in xlsx file with POI

不问归期 提交于 2019-12-22 09:15:02
问题 Is there any way to embed a document (e.g. pdf) in an xlsx file using Apache POI? It seems you can read embedded documents using workbook.getAllEmbedds() , but I can't find a way to insert any when writing a file. 回答1: This should help: similar question with answer User has created a patch for Apache poi with which you can include arbitary file into excel sheet patch link here Hope this helps. 来源: https://stackoverflow.com/questions/10280687/embed-document-in-xlsx-file-with-poi

How to check a column is hidden or not in excel file using apache poi

折月煮酒 提交于 2019-12-22 08:55:35
问题 I am trying to parse a xls file using apache poi. Is it possible to check whether a column is hidden or not. How can I get the width of a particular column. Example: According to the post here it checks if the row is hidden or not. Similarly I want to check the width of a column ( or check if the column is hidden or not) 回答1: you can set a column as hidden/unhidden by using sheet.setColumnHidden(int columnIndex, boolean hidden); e.g. sheet.setColumnHidden(2, true); // this will hide the

How to check a column is hidden or not in excel file using apache poi

点点圈 提交于 2019-12-22 08:54:18
问题 I am trying to parse a xls file using apache poi. Is it possible to check whether a column is hidden or not. How can I get the width of a particular column. Example: According to the post here it checks if the row is hidden or not. Similarly I want to check the width of a column ( or check if the column is hidden or not) 回答1: you can set a column as hidden/unhidden by using sheet.setColumnHidden(int columnIndex, boolean hidden); e.g. sheet.setColumnHidden(2, true); // this will hide the