How to get DataValidation in Apache POI 3.9? - apache-poi

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

Related

XSSFWorkbook.setActiveSheet() equivalent in JasperReports?

We're using JasperReports 6.13.0 to generate XLSX format reports. We have a requirement where we need to show a particular sheet as default visible(instead of the first sheet) whenever the user opens the generated XLSX report.
My question is, do we have this feature in JasperReports? I couldn't find anything related to it in the documentation.
Note: In Apache POI, we can achieve this functionality using: XSSFWorkbook.setActiveSheet(int index)
JasperReports doesn't currently include this feature.
You can consider patching the JasperReports code to add it. What you would need to do is to add something like the following line in XlsxWorkbookHelper.exportHeader after the line with workbookPr.
write("<bookViews><workbookView activeTab=\"" + activeSheet + "\"/></bookViews>\\n");
You'd also need to pass the active sheet index somehow from the exporter.
Alternatively, you can export to XLSX using JasperReports and then open the file with POI and set the active sheet.

Apache POI HSSF/XSSF support for newer Versions of Excel

Currently im working on a project which includes the Apache POI to read and write Excel files.
Im looking for a source that basically says that the POI (HSSF/XSSF) works for newer versions of Excel as well, since it says on the official website that HSSF supports Excel 97-2007. Yet i got Excel 2016 and when i'm trying to read data out of the file it's working just fine. Im Struggling to find something because i don't know where to look, and my first language isn't english so skimming through the changelogs is really hard for me.
Please let me know if this was a stupid question.
Thanks in advance.

JasperReports: How to define a header in Excel

I'm cleaning up a legacy application which uses Jasper Reports 3.1.2, and am trying to figure out how to define a header that shows up as the header in the generated Excel spreadsheet (under Page Setup, Header/Footer). The existing code already does this for the footer using:
exportParameters.put(JRXlsAbstractExporterParameter.LEFT_FOOTER, "My footer text");
I can't find an equivalent parameter for the header in the JRXlsAbstractExporterParameter class.
Is there a way to do this in the JRXML template, or via the API ?
Adding a screenshot from the generated Excel report which shows that Excel detects the footer that was defined in the JRXlsAbstractExporterParameter class (code above). I am trying to do the same with the header.
Looking at JasperForge Config Reference, the JRXML header and footer properties are not supported until 3.7.5. In my opinion, it would be easier upgrading to at least version 3.7.5 to accomplish what you're attempting, update your jrxml files, and do regression testing with your existing reports. If upgrading is not possible and you're familiar with POI or JExcelAPI, I would suggest extending the JRXlsExporter or JRExcelApiExporter (limited to two links...sorry) and use custom exporter parameters in your API.
The version of Jasper Reports you're using really limits what you can do in excel. If you do upgrade, you may want to research the XLS properties available in versions above 4.0. If you're going to be doing more excel specific formatting with your existing reports, it would be more beneficial to uprade to a version higher than 4.0.

Embed document in xlsx file with 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.

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!

Resources