LibreOffice Calc evaluation requires specific libraries and a method for comparing spreadsheet data.
Required Libraries
pip install openpyxl pandas lxml xmltodict
Generating CSV from XLSX
To compare displayed cell values, you must first convert the XLSX to CSV using the following command structure:
libreoffice --convert-to "csv:Text - txt - csv (StarCalc):44,34,UTF8,,,,false,true,true,false,false,1" --out-dir /home/user /home/user/abc.xlsx
Note: The final 1 in the conversion options specifies the sheet number (starting from 1) to export.
Using compare_table
Evaluation relies on the compare_table function, which accepts two filenames and an options list of rules. Each rule requires a type:
sheet_data: Compares internal cell values via pandoc.sheet_print: Compares shown cell values via CSV (requires the CSV generation step above).
Sheet Indexing (sheet_idx0, sheet_idx1, or sheet_idx):
- Integer
i: Extracts the $i$-th sheet from the result (starts at 0). - String with prefix:
R: Extract from result xlsx.E: Extract from expected (golden) xlsx.I: Indicates a sheet number (starting from 0).N: Indicates a sheet name (e.g., "Sheet1").
Rules can also use matching patterns like {"method": "eq", "ref": "abc"}, which are processed by utils._match_value_to_rule.
libreoffice --convert-to "csv:Text - txt - csv (StarCalc):44,34,UTF8,,,,false,true,true,false,false,1" --out-dir /home/user /home/user/abc.xlsx