Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
221 views
in Technique[技术] by (71.8m points)

Write ODF Spreadsheet documents with ODFDOM Java API

I want to update an old program from Java 8 to Java 15 with modules and therefore I rewrite and update a lot of code. Everything works fine until the update of the library to write spreadsheet documents.

In the old version, I used the org.odftoolkit with the simple-api with maven.

<dependency>
    <groupId>org.odftoolkit</groupId>
    <artifactId>odfdom-java</artifactId>
    <version>0.8.7</version>
</dependency>
<dependency>
    <groupId>org.odftoolkit</groupId>
    <artifactId>simple-java</artifactId>
    <version>0.4</version>
</dependency>

As described here, this API is deprecated and I want to step over to the current ODFDOM API. But the documentation is not current with the latest version and I did not found an example for the java module.

I added the maven dependencies, but the question is how to add this to the module-info.java file. All my attempts with

requires org.odftoolkit.odfdom.doc.table;

or equal ones have failed miserably.

My question may occur simply, but for me, it is a big mountain. What is the right way to do this? Thank you for any input.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Derive the module name

jar --file=/path/to/your/jar/odfdom-java-0.8.7.jar --describe-module

Add the directive for dependency

In your case, if these dependencies are not yet modular or declare their Automatic-Module-Name. You can still make use of the derived name in the module directives to make use of the public classes within the packages of the modules.

requires odfdom.java;
requires simple.java;

As the specification of Module declaration guides:

requires {RequiresModifier} ModuleName ;

RequiresModifier:
(one of)
transitive static

you need to specify the module name instead of the packages that your code would rely upon.

Additionally, upon some research, I could find out, that you might want to test the BETA or RC version of the toolkit, as listed in the repository tags and maven central.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...