Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

package com.codename1.spreadsheet

Spreadsheet files and formulas.

A Workbook is read from, and written to, an Excel .xlsx file, an OpenDocument .ods file or separated text (CSV and TSV). Each of its Sheets is a com.codename1.ui.table.TableModel, so a sheet is shown and edited by handing it to a com.codename1.ui.table.DataGrid, and Workbook.fromGrid turns what a grid shows back into a file.

Workbook book = new Workbook();
// com.codename1.ui has a Sheet too, hence the full name
com.codename1.spreadsheet.Sheet sheet = book.addSheet("Prices");
sheet.setCellValue("A1", "Item");
sheet.setCellValue("B1", "Price");
sheet.setCellValue("A2", "Tea");
sheet.setCellValue("B2", Double.valueOf(3.5));
sheet.setCellFormula("B3", "=SUM(B2:B2)");
sheet.setHeaderRow(true);
DataGrid grid = new DataGrid(sheet);
grid.setColumns(sheet.createColumns());
Form form = new Form("Prices", new BorderLayout());
form.add(BorderLayout.CENTER, grid);
form.show();

Cells keep their types: a number is a Double, a date a java.util.Date, a logical value a Boolean, and an error such as #DIV/0! a CellError. Number formats are Excel’s format codes, and Sheet.getCellText answers what a spreadsheet would show.

Formulas are live. They are written the way Excel writes them, whichever format a file is in, and a change to a cell recalculates every formula that reads it and tells the sheet’s listeners which cells changed, so a grid repaints them. Workbook.getSupportedFunctions lists the functions a formula can call. A formula this package cannot evaluate is never lost: its text is kept and written back, and its cell shows the value the file stored for it.

Nothing in com.codename1.ui.table refers to this package, so an application that does not use it does not carry it.

Types

class CellErrorAn error a cell holds instead of a value, such as #DIV/0!.
class FormulaBarThe bar a spreadsheet application has over its cells: the address of the selected cell, and its formula, or its value, in an editor of one line.
class SheetOne sheet of a Workbook: a grid of cells with no fixed size, each empty or holding a number, text, a logical value, an error or a formula.
class WorkbookA spreadsheet: sheets of cells that hold numbers, text, dates, logical values and formulas, read from and written to Excel (.xlsx), OpenDocument (.ods), CSV and TSV files.