1
0
Fork
You've already forked ods-reader
0
Java library for reading OpenDocument tables (ODS file)
Java 100%
2025年02月12日 10:48:45 +01:00
.github commit badge 2025年02月12日 07:10:52 +00:00
.mvn/wrapper added Maven wrapper 2024年11月28日 20:17:57 +01:00
src Use the value of repeated cells 2025年02月12日 08:09:39 +01:00
.gitignore preparations for version 1.1 2024年11月28日 15:59:46 +01:00
.travis.yml Initial import. 2015年04月15日 13:04:44 +02:00
LICENSE preparations for version 1.1 2024年11月28日 15:59:46 +01:00
mvnw added Maven wrapper 2024年11月28日 20:17:57 +01:00
mvnw.cmd added Maven wrapper 2024年11月28日 20:17:57 +01:00
pom.xml [maven-release-plugin] prepare for next development iteration 2025年02月12日 10:48:45 +01:00
README.md Update README.md 2024年11月30日 17:51:16 +01:00
rules.xml updated libraries 2025年02月12日 08:10:02 +01:00

ods-reader

Maven Central version Coverage

You want to import very large OpenDocument tables (ODS file) and worry about memory usage? In that case the ods-reader might be interesting for you. Instead of loading the entire document, it is a pull-based reader. It therefore has a very low memory consumption, even with huge documents.

Usage

Here is an example how to use the ods-reader:

Documentdoc=newDocument(newFile("myTable.ods"));Tabletable=doc.nextTable();Rowrow=table.nextRow();while(row!=null){Cella=row.nextCell();Cellb=row.nextCell();System.out.println(a.getContent+"\t"+b.getContent);row=table.nextRow();}

Maven

The library is available at Maven Central. You can add a dependency to ods-reader to you project like this:

<dependency>
 <groupId>de.zedlitz</groupId>
 <artifactId>ods-reader</artifactId>
 <version>1.0.1</version>
</dependency>

Cell types

ODS distinguishes between the value that is displayed for humans and the machine-readable value. The value that is displayed for humans depends on the language selected for the document. The method getContent() is used to get the language depending human-readable value.

The machine-reable value can be read using specialized methods that return suitable Java objects. Here is an example:

if("date".equals(cell.getValueType())){if(cell.isDateTime()){LocalDateTimedateTime=cell.asDateTime();}else{LocalDatedate=cell.asDate();}}elseif("boolean".equals(cell.getValueType())){booleanb=cell.asBoolean();}elseif("time".equals(cell.getValueType())){LocalTimetime=cell.asTime();}elseif(cell.getValue()!=null){result=cell.getValue();}else{result=cell.getContent();}