Skip to contents

Writes one worksheet per table. This is deliberately one-way: a spreadsheet cell holds a single value, so several SeaTable column types have no faithful representation.

Usage

hb_write_xlsx(x, path, ..., tables = NULL)

Arguments

x

A harbour_dtable, or a harbour_client to read from first.

path

Destination .xlsx path.

...

These dots are for future extensions and must be empty.

tables

Table names to export. Default: all of them.

Value

path, invisibly.

Details

Each sheet is named after its table, made to fit Excel's rules for sheet names: cut to 31 characters, with each of /, \, ?, *, : or a square bracket replaced by _. Excel compares sheet names ignoring case, so table names that would give sheet names differing only in the case of the letters A to Z, such as Samples and samples, are rejected before anything is written. So is text longer than the 32,767 characters a workbook cell holds.

What is lost

  • multiple-select, collaborator and image cells are joined with ", ".

  • file cells are reduced to their file names.

  • link and link-formula cells reference rows in other tables and are exported as their display values.

  • formula columns export their computed value, not the formula.

  • geolocation cells are written as their values, in the order the source stores them, without the field names: "11.5761, 48.1371" does not say which number is the latitude.

  • digital-sign cells are written as a placeholder, "<object>", or as their bare values, depending on how the source stores them; the signature itself is not exported. button columns hold no value and are written as missing.

  • A CSV stores numbers with 15 significant digits and a workbook with 16, so a double that needs more, such as 0.1 + 0.2, reads back very slightly different. In a CSV, date-times are written by as.character(), whose layout depends on the version of R. Use hb_write_dtable() for full precision.

  • Views, filters, colours, column widths and every other piece of base configuration have no cell to live in.

harbouR reports which columns were flattened. To keep everything, write a .dtable with hb_write_dtable() instead.

Examples

base <- hb_read_dtable(
  system.file("extdata", "example.dtable", package = "harbouR")
)
out <- tempfile(fileext = ".xlsx")
hb_write_xlsx(base, out)
#> ! 7 columns were flattened to text.
#> • Samples$Tags, Samples$Collaborators, Samples$Photos, Samples$Reports,
#>   Samples$Where, Samples$Action, and Samples$Signature
#> ℹ A spreadsheet cell holds one value. Use `hb_write_dtable()` to keep the
#>   structure.
unlink(out)