GithubHelp home page GithubHelp logo

qmor / fastods Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jferard/fastods

0.0 2.0 0.0 2.59 MB

A very fast and lightweight (no dependency) library for creating ODS (Open Document Spreadsheet, mainly for Calc) files in Java. It's a Martin Schulz's SimpleODS fork

License: GNU General Public License v3.0

Java 99.78% Python 0.22%

fastods's Introduction

Build Status Code Coverage

FastODS

(C) J. Férard 2016-2018

(C) M. Schulz 2008-2013 for SimpleODS

A very fast and lightweight (no dependency) library for creating ODS (Open Document Spreadsheet, mainly for Calc) files in Java. It's a Martin Schulz's SimpleODS fork.

Please note that FastODS is almost ready for production use. The version 1.0 is coming.

Ask a question: feel free to ask a question.

Table of contents

Why FastODS?

Because I need to write big and simple ODS files very fast in Java.

There are some very good libraries for OASIS Open Document Format, like Simple ODF or JOpenDocument, but they are a little bit slow and cumberstone for only writing very simple spreadsheets. There is a simple and fast library by Martin Schulz, Simple ODS, but it is now discontinued, outdated (Java 1.3), has a few limitations (incorrect handling of UTF-8 encoding, missing XML escaping for attributes) and can be speed up.

FastODS is a fork of SimpleODS that aims to be a very fast ODS writing library in Java.

Limitations

FastODS won't deal with odt, odg, odf, or other od_ files. It won't even read ods files. Because it doesn't use XML internally, but only for writing files. That's why it is fast and lightweight.

It's an OpenDocument producer (Open Document Format for Office Applications (OpenDocument) Version 1.2, 2.3.1) and only an OpenDocument producer:

An OpenDocument producer is a program that creates at least one conforming OpenDocument document

Installation

Standard

Add the following dependency to your POM:

<dependency>
		<groupId>com.github.jferard</groupId>
		<artifactId>fastods</artifactId>
		<version>0.6.0</version>
</dependency>

From sources

Type the following command:

git clone https://github.com/jferard/fastods.git

Then:

mvn clean install

It doesn't compile!

For reasons beyond my control, I'm stuck for this project with Java 6, and thus I need the tools.jar archive. If the default JRE on your computer is beyond version 9, maven won't find tools.jar. Here's a workaround for Linux:

JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64" mvn clean install

On Windows, try (not tested):

cmd /C "set JAVA_HOME="C:\Program Files\Java\jdk..." mvn clean install"

From jar

First download the jar file from the latest release.

Then run the following command to install the jar in your local repo:

mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=fastods-<version>.jar

Usage

In your POM, you'll have to include the following dependency:

<dependencies>
	...
	<dependency>
		<groupId>com.github.jferard</groupId>
		<artifactId>fastods</artifactId>
		<version>[set the version number here]</version>
	</dependency>
	...
</dependencies>

Examples

Basic example

final OdsFactory odsFactory = OdsFactory.create(Logger.getLogger("example"), Locale.US);
final AnonymousOdsFileWriter writer = odsFactory.createWriter();
final OdsDocument document = writer.document();
final Table table = document.addTable("test");

final TableCellStyle style = TableCellStyle.builder("green cell style").backgroundColor("#00ff00").build();
for (int y = 0; y < 50; y++) {
	final TableRow row = table.nextRow();
	final TableCellWalker cell = row.getWalker();
	for (int x = 0; x < 5; x++) {
		cell.setFloatValue(x*y);
		cell.setStyle(style);
		cell.next();
	}
}

writer.saveAs(new File("generated_files", "readme_example.ods"));

Other examples

Other examples are implemented as integration tests: OdsFileCreationIT.java, OdsFileWithHeaderAndFooterCreationIT.java, etc. The sources are quite simple.

To run those examples, one has to run:

mvn verify

The resulting ods files are written in current directory, and can be opened with LibreOffice or OpenOffice.

Speed

Let's be concrete : FastODS is approximately twice as fast as SimpleODS and ten times faster than JOpenDocument for writing large ODS files. (SimpleODF is clearly not the right tool to write large ODS files.)

For more details, see https://github.com/jferard/fastods/wiki/Benchmarking-and-profiling.

History

See https://github.com/jferard/fastods/releases

fastods's People

Contributors

jferard avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.