Skip to content
Raphael Stoeckli edited this page Aug 25, 2018 · 14 revisions

Welcome to the PicoXLSX4j wiki!

Introduction

PicoXLSX is a port of PicoXLSX for C#. It is a small Java library to create Microsoft Excel files (XLSX for Office 2007 or newer) in an easy and native way. This means:

  • No need for an installation of Microsoft Office
  • No need for Office interop/DCOM or other bridging libraries
  • No need for 3rd party libraries
  • Pure usage of standard JRE

See the Change Log for recent updates.

Requirements

PicoXLSX4j was created with Java 8 and is fully compatible with Java 7
The only requirements for development are a current JDK to develop and JRE to run.

Installation

As JAR

Simply place the PicoXLSX4j.jar into the lib folder of your project and create a library reference to it in your IDE.

As source files

Place all .java files from the PicoXLSX4j source folder into your project. The folder structure defines the packages. Please use refactoring if you want to relocate the files.

Maven

Add the following information to your POM file within the <dependencies> tag:

<dependency>
    <groupId>ch.rabanti</groupId>
    <artifactId>picoxlsx4j</artifactId>
    <version>VERSION NUMBER</version>
</dependency>

Important: The VERSION NUMBER must be defined (e.g. 2.3.1). Please see the version number of Maven Central Maven Central or check the Change Log for the most recent version. The keywords LATEST and RELEASE are only valid in Maven 2, not 3 and newer.

Usage

Quick Start (shortened syntax)

 Workbook workbook = new Workbook("myWorkbook.xlsx", "Sheet1");         // Create new workbook with a worksheet called Sheet1
 workbook.WS.value("Some Data");                                        // Add cell A1
 workbook.WS.formula("=A1");                                            // Add formula to cell B1
 workbook.WS.down();                                                    // Go to row 2
 workbook.WS.value(new Date(), BasicStyles.Bold());                     // Add formatted value to cell A2
 try{
   workbook.save();                                                     // Save the workbook as myWorkbook.xlsx
 } catch (Exception ex) {}

Quick Start (regular syntax)

 Workbook workbook = new Workbook("myWorkbook.xlsx", "Sheet1");       // Create new workbook with a worksheet called Sheet1
 workbook.getCurrentWorksheet().addNextCell("Some Data");             // Add cell A1
 workbook.getCurrentWorksheet().addNextCell(42);                      // Add cell B1
 workbook.getCurrentWorksheet().goToNextRow();                        // Go to row 2
 workbook.getCurrentWorksheet().addNextCell(new Date());              // Add cell A2
 try {
   workbook.Save();                                                   // Save the workbook as myWorkbook.xlsx
 } catch (Exception ex) {}

Further References

See the full API-Documentation at: https://rabanti-github.github.io/PicoXLSX4j/.
The Demo class contains several simple use cases. You can find also the full documentation in the Javadoc-Folder or as Javadoc annotations in the .java files.