Embed document in xlsx file with POI - apache-poi

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.

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.

Related

reading XLSB from apache poi

I've read it stated on multiple SO questions that Apache POI 3.16-beta3 has read-only support for xlsb files.
I am using poi 3.17 and cannot find any documentation or examples of this feature. The best I can find is an example of extracting raw text only via XSSFBEventBasedExcelExtractor, but this appears to be quite old (2010?) and I am unsure if this is the referenced capability.
Is there any documentation or examples of using poi to read xlsb files with the read-only parsing alluded to in the comments of this question: Exception reading XLSB File Apache POI java.io.CharConversionException and in an answer to this: Reading data from .xlsb in Clojure by Tim Allison ?
The functionality that Tim was referring to is actually XSSFBEventBasedExcelExtractor, and it was added in Apache POI 3.16. It can be used to extract text-content from the file.
There is currently no functionality to fully read the file content, though.
See also the JavaDoc for this class.

How to get DataValidation in Apache POI 3.9?

I am using Apache POI to write and read excel files,my poi version is 3.9,but now I faced a problem and do not find a good solution to solve it.
First I am use poi to write some datas to the excel table and will use DataValidation to add some prompt information in the table header,as the picture shown below:
The value in the cell is ABSInterention,and the prompt title is wrxuoh.After the excel generated successfully,other users will add some modification to the data cell and I need to read and parse the excel file and I want to get the prompt value wrxuoh again.So my question is:
When I read excel file using POI3.9,how can I get all the DataValidations for the current sheet?
I am using HSSFWorkbook and HSSFSheet.I found there is a method called getDataValidations in the POI Sheet,but I can not find this method in my poi3.9 jar file and also can not find it in the POI3.9 javadoc.
any help would be grateful!
Promoting a comment to an answer - you can't
That functionality was added to Apache POI after the 3.9 release you mention in your question
As per the Apache POI Changelog, you need to upgrade to at least POI 3.11 beta 3 to use that feature. 3.11 final, when it comes out shortly, will be the first stable release to include it

How to get the content of an excel file in struts2 after uploading?

I'm working on Struts2 framework. I need to upload an excel file to the buffer so that I can extract its informations and print them into a table in a jsp page. I followed this tutorial : http://www.roseindia.net/struts/struts2/struts-2-file-upload.shtml , and so I could upload any type of file. My question is then : how can restrict the type into .xls and .xlsx ? and how can I get the content of the rows existing in the excel file? I read somewhere that i can use the Apache POI API ... but I couldn't get much how to do. Thank you.
Have you seen the Struts 2 File Upload Tutorial ?
It shows how to restrict to certain mime types.
You need the mime types described here for excel.
There is an opensource library called jxl. After you haveuploaded your file to your server you can read it in and iterate through ght rows. Its very easy to do.

Excel comments using xssf eventusermodel using apache poi 3.7

Here is a link to a code that uses apache 3.7.
http://massapi.com/source/poi-3.7/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java.html
How can i edit this code to get the comments in excel file?
Comments are stored in a different stream (Document Part) to the sheet, so you'd need to navigate from the sheet to the comments (if present) and parse that
The relation will be of type XSSFRelation.SHEET_COMMENTS
As the comments part is normally fairly small, you should be fine to just access it using normal UserModel code. CommentsTable is the class that will give you easy access to it, pass that comments part and the relation from the sheet and work your way through the comments in turn
If you get it working, send a patch to POI so it gets included in future!

How to access a excel file in CF8?

How to read an excel file from cfm page?
That depends on what you want to do. If you simply need to upload the file, you can use the cffile tag (CF8 documentation here).
If you want to extract data from it, you may want to look at Ben Nadel's POI Utility CFC. (Note that it's not been updated since the release of CF9 because of the introduction of the cfspreadsheet tag in that version of ColdFusion.)

Resources