Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create xlsx Excel file #6174

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Create xlsx Excel file #6174

wants to merge 2 commits into from

Conversation

BartChris
Copy link
Collaborator

@BartChris BartChris commented Aug 7, 2024

resolves #6172
This PR changes the used classes in order to create xlsx files when exporting an Excel file to be compatible with newer Excel versions.

I am using SXSSFWorkbook to generate Excel and PDF files, which has a lower memory footprint by flushing intermediary files to disk. See: https://www.baeldung.com/java-apache-poi-workbook-evaluation

This will hopefully enable exporting even longer lists of processes to Excel in the future.

The dependency issues described in this PR were resolved by #6362

@BartChris BartChris marked this pull request as draft August 7, 2024 14:58
@stweil
Copy link
Member

stweil commented Aug 7, 2024

The CI failure is unrelated to this PR (which looks nice, but I did not test it). As you are still working on this PR, I suggest to fix the typo in the commit message (xslx -> xlsx).

@BartChris BartChris changed the title Create xslx Excel file Create xlsx Excel file Aug 8, 2024
@BartChris
Copy link
Collaborator Author

BartChris commented Dec 20, 2024

Hmm, i cannot make it work with Apache POI > 5.2.3. (see #6266) The newer version brought a lot of dependency updates (https://poi.apache.org/changes.html) and my Pull Request does not work anymore. (Excel file is empty, PDF works)
Old xls-Excel Files (HSSF) still seem to function.

@BartChris
Copy link
Collaborator Author

BartChris commented Dec 20, 2024

This could be a nasty (transitive) dependency issue involving Apache commons compress. POI 5.2.5 requires commons-compress 1.25.0, on my system i still found some older binaries, which seem to be generated when doing mvn clean install.

mvn dependency:tree | grep "commons-compress"
[INFO] |  +- org.apache.commons:commons-compress:jar:1.23.0:compile
mvn dependency:tree -Dverbose | grep "commons-compress" -B 5
[INFO] |  +- javax.inject:javax.inject:jar:1:test
[INFO] |  +- org.codehaus.plexus:plexus-utils:jar:4.0.0:test
[INFO] |  +- org.codehaus.plexus:plexus-io:jar:3.4.1:test
[INFO] |  |  +- (javax.inject:javax.inject:jar:1:test - omitted for duplicate)
[INFO] |  |  \- (org.codehaus.plexus:plexus-utils:jar:3.5.0:test - omitted for conflict with 4.0.0)
[INFO] |  +- (org.apache.commons:commons-compress:jar:1.23.0:compile - scope updated from test; omitted for duplicate)
--
[INFO] |  |  \- (org.apache.logging.log4j:log4j-api:jar:2.21.1:compile - omitted for conflict with 2.19.0)
[INFO] |  +- org.apache.poi:poi-ooxml-lite:jar:5.2.5:compile
[INFO] |  |  \- (org.apache.xmlbeans:xmlbeans:jar:5.2.0:compile - omitted for duplicate)
[INFO] |  +- org.apache.xmlbeans:xmlbeans:jar:5.2.0:compile
[INFO] |  |  \- (org.apache.logging.log4j:log4j-api:jar:2.21.1:compile - omitted for conflict with 2.19.0)
[INFO] |  +- org.apache.commons:commons-compress:jar:1.23.0:compile

Old version seems to come from plexus-archiver:

https://mvnrepository.com/artifact/org.codehaus.plexus/plexus-archiver/4.8.0

enforcing commons-compress 1.25.0 fixes the issue

   <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-compress</artifactId>
                <version>1.25.0</version>
    </dependency>

Dependency check after fix:
mvn dependency:tree -Dverbose -Dincludes=org.apache.commons:commons-compress

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ kitodo ---
[INFO] org.kitodo:kitodo:war:3.9.0-SNAPSHOT
[INFO] +- org.codehaus.plexus:plexus-archiver:jar:4.8.0:test
[INFO] |  \- (org.apache.commons:commons-compress:jar:1.25.0:compile - version managed from 1.23.0; scope updated from test; omitted for duplicate)
[INFO] \- org.apache.poi:poi-ooxml:jar:5.2.5:compile
[INFO]    \- org.apache.commons:commons-compress:jar:1.25.0:compile

Edit:
Best would probably be to update
poi
https://mvnrepository.com/artifact/org.apache.poi/poi/5.3.0
and plexus-archiver
https://mvnrepository.com/artifact/org.codehaus.plexus/plexus-archiver/4.10.0

to also adress a CVE in commons-compress.

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-26308
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-25710

@BartChris BartChris marked this pull request as ready for review January 23, 2025 17:17
wb.write(out);
wb.close();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wb.close() now also deletes temporary files from disk. https://poi.apache.org/changes.html#5.3.0

@@ -1587,6 +1585,7 @@ public void generateResultAsPdf(String filter, boolean showClosedProcesses, bool
}

document.close();
wb.close();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wb.close() now also deletes temporary files from disk. https://poi.apache.org/changes.html#5.3.0

@solth solth requested a review from stweil January 24, 2025 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Excel-Export: Upgrade to .xlsx
2 participants