Reads spreadsheet data from xlsx workbooks using a bundled copy of the xlsxio reader (<https://github.com/brechtsanders/xlsxio>), so that no system XML or ZIP library is required. The Expat parser and
Developer toolsR · CGitHub @pedrobtzOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
No updates detected yet. GitHub releases will appear here.
Owners of public repositories under a personal GitHub account can sign in to verify ownership and manage the introduction themselves. No administrator approval is needed.
Sign in, generate a verification file, and commit it to this repository’s default branch within 30 minutes. Files on other branches or forks do not count. Then check the file below to manage the project without administrator approval. Keep the file to retain your access.
If needed, you will go to sign-in. After signing in, return here and press your chosen verification button again.
Run /nomorevibe verify in your project folder to verify ownership and manage the introduction yourself.
Verify in one minuteAsk about other verification options
Reads spreadsheet data from xlsx workbooks using a bundled copy of the xlsxio reader (<https://github.com/brechtsanders/xlsxio>), so that no system XML or ZIP library is required. The Expat parser and the miniz ZIP reader are linked statically at install time from the zuxml and zukomp packages, which means there is no run-time dependency on either of them. Worksheets are read as a stream, so a workbook does not have to be held in memory in full. Writing workbooks is out of scope.
Taken from the repository README
Loading the full README. The saved excerpt is shown below.
Read .xlsx workbooks from R, password-protected ones included, with no
system XML, ZIP or cryptography library required.
zuxlsx bundles the xlsxio reader and
links the Expat parser, the miniz ZIP reader and TF-PSA-Crypto statically at
install time, out of the sibling packages
zuxml,
zukomp and
zucrypt. Those are LinkingTo
dependencies only: the archives end up inside zuxlsx.so, so none of the
three has to be installed or loadable once zuxlsx is built.
Writing workbooks is out of scope.Read the full README ↗Read .xlsx workbooks from R, password-protected ones included, with no
system XML, ZIP or cryptography library required.
zuxlsx bundles the xlsxio reader and
links the Expat parser, the
miniz ZIP reader and
TF-PSA-Crypto statically at
install time, out of the sibling packages
zuxml,
zukomp and
zucrypt. Those are LinkingTo
dependencies only: the archives end up inside zuxlsx.so, so none of the
three has to be installed or loadable once zuxlsx is built.
Writing workbooks is out of scope.
library(zuxlsx)
path <- system.file("extdata", "two-sheets.xlsx", package = "zuxlsx")
xlsx_sheets(path) # "readings" "notes"
xlsx_read(path) # first worksheet as a data frame
xlsx_read(path, sheet = "readings", range = "A1:B3")
xlsx_read() gives each column the type its cells support: logical, double,
character, Date or POSIXct. A column that cannot hold its cells becomes
character rather than failing. range takes A1 notation, and either corner
may name a cell, a column or a row, so "B2:D10", "A:C" and "2:10" are
all accepted.
Both Excel date systems are handled. The workbook's own date1904 setting
decides which is used, and the 1900 system's phantom 29 February 1900 is
accounted for, so dates before March 1900 are not a day early.
A password-protected workbook is read by passing its password, to any of the readers:
xlsx_read("protected.xlsx", password = "s3cret")
It is decrypted in memory and never written to disk. zuxlsx decrypts agile encryption, which Excel has written since 2013, and checks the integrity code stored with the file before decrypting anything. Office 2007's older standard encryption is recognised and refused by name.
Underneath, for worksheets that are not rectangular enough for a data frame:
xlsx_cells(path) # one row per cell: position, type, text, numeric value
xlsx_rows(path) # a worksheet row by row as text, padded to a rectangle
# A chunk at a time; returning FALSE stops the read, so finding something
# near the top of a large worksheet does not pay for the rest.
xlsx_stream_cells(path, callback = function(cells) { str(cells); FALSE })
zuxlsx needs zuxml, zukomp and zucrypt at build time, and its
configure script will stop with an explanatory message if their static
archives are missing. All three are on CRAN, so installing zuxlsx installs
them first:
install.packages("zuxlsx")
The development version is on GitHub:
# install.packages("pak")
pak::pak("pedrobtz/zuxlsx")
Every error carries a condition class, so calling code can tell a corrupt archive from a missing file without matching on message text:
tryCatch(
xlsx_sheets("broken.xlsx"),
zuxlsx_zip_error = function(e) "not a readable ZIP archive",
zuxlsx_ooxml_error = function(e) "a ZIP, but not a workbook",
zuxlsx_error = function(e) "something else went wrong"
)
See ?"zuxlsx-conditions" for the full list.
The bundled xlsxio reader is MIT licensed and is never edited in place. It is
re-derived from the pristine 0.2.36 release archive plus the patches in
tools/patches/xlsxio/, and tools/vendor/verify checks offline that the
committed tree, the manifests and the attribution all still agree.