xlsx
Excel workbooks with the Simple Office tools
Use the tools of the Simple Office add-on: addon__office__read-xlsx,
addon__office__edit-xlsx and addon__office__create-xlsx. A file is a
path in the user's files, such as /reports/plan.xlsx.
Read first
- Call
read-xlsxwith the path only. You get the sheet names and the
cell values of each sheet, row by row.
- For a large workbook, call
read-xlsxagain withsheetto read one
sheet.
- Answer from what you read. Do not guess a value you did not read.
Change cells
- Read the sheet first, so that you know the cell addresses.
- Call
edit-xlsxwithpath,sheetandcells. Each cell has aref
such as B3 and exactly one of text, number, formula or clear.
- Change only the cells that must change. Do not create the workbook again
to change a cell.
- A formula is a string that starts with
=, such as=SUM(B2:B9). The
file is not recalculated: say that the value shows when the file is
opened in a spreadsheet program.
- To add a sheet, give
addSheetwith its name in the same call. - Tell the user the sheet and the range you changed.
Create a workbook
Use create-xlsx with path and a comma-separated csv string, only when
no file exists. It creates exactly one sheet; optional sheet defaults to
Sheet1, and optional title is metadata. All arguments are strings. The
former sheets/rows creation structure is no longer accepted.
Example: {"path":"/reports/status.xlsx","csv":"Name,Status\nWorker,Ready\n","sheet":"Status"}.
Standard CSV quoting, escaped quotes, multiline cells and LF/CRLF are supported.
Every nonempty field stays text, including leading zeros and values beginning
with =, +, - or @; no formulas or numbers are inferred. Empty cells
stay blank in place. The first row is ordinary data, not a styled header.
Use edit-xlsx afterwards for explicit numbers or formulas. Ragged rows,
malformed quoting, empty content and invalid sheet names are refused.
Limits: 5000 rows, 200 columns and 100000 grid cells, including empty fields.
If the path is taken, the old file stays and the new one is saved next to it:
give the user the new path.
When the tools cannot do it
The tools do not make charts, pivot tables, macros, conditional formats or
cell styles. Say so before you start, and offer what the tools can do. Do
not describe a manual method instead.
