All errors raised by zuxlsx carry a condition class, so that they can be
caught by kind rather than by matching on the message text, which is not
stable. Every class below is a subclass of zuxlsx_error.
Details
zuxlsx_input_errorAn argument was not usable: a
paththat is not a single string, does not exist or is a directory; asheet,range,col_names,callback,chunk_sizeorpasswordof the wrong kind; or arangereaching pastXFD1048576.zuxlsx_zip_errorThe file could not be opened as a ZIP archive – it is unreadable, truncated, or not a ZIP at all – or a worksheet's compressed data failed its integrity check.
zuxlsx_xml_errorA part of the workbook is not well-formed XML. Raised in preference to
zuxlsx_ooxml_errorwhen the failure is the XML itself rather than what it says, and names the part or worksheet and the line. A worksheet that breaks off part-way is reported this way rather than read as a shorter one.zuxlsx_ooxml_errorThe XML is well formed but is not a valid workbook: the archive declares no worksheet, or a worksheet refers to a cell beyond
XFD1048576or to a shared string that does not exist.zuxlsx_sheet_errorThe workbook opened, but the requested worksheet is not in it.
zuxlsx_encrypted_errorThe workbook is password-protected and no
passwordwas given. It is also a subclass ofzuxlsx_unsupported_format_error, so a handler for that class catches it too, while one forzuxlsx_encrypted_erroralone can prompt for a password.zuxlsx_password_errorThe
passwordgiven is not the workbook's. A subclass ofzuxlsx_encrypted_error, so one handler covers a password that is missing and one that is wrong. A damaged encryption header is indistinguishable from a wrong password, by design of the format.zuxlsx_integrity_errorA password-protected workbook is damaged: its encrypted package does not match the integrity code stored with it, or its container or encryption parameters are inconsistent. Nothing is decrypted from a file that fails this check.
zuxlsx_unsupported_format_errorThe file is a spreadsheet, but not one zuxlsx can read: an
.xlsb, whose worksheets are binary rather than XML; a legacy.xls; or a workbook encrypted with a scheme other than agile encryption, such as Office 2007's standard encryption. Raised in preference to reporting such a file as corrupt, which is what it otherwise looks like.zuxlsx_memory_errorAn allocation failed while reading.
A failure of the cryptographic backend while decrypting, and an internal
error that should not happen, carry zuxlsx_error alone.
Conditions carry the offending path in a path element, where one
applies.
Examples
tryCatch(
xlsx_sheets("no-such-file.xlsx"),
zuxlsx_input_error = function(e) conditionMessage(e)
)
#> [1] "`path` does not exist: no-such-file.xlsx"