Crates.io | xls2txt |
lib.rs | xls2txt |
version | 1.2.1 |
source | src |
created_at | 2019-11-11 16:38:04.078377 |
updated_at | 2023-06-05 18:35:58.127738 |
description | Command-line utility to convert stylesheets (ODS or excel) to text |
homepage | |
repository | https://github.com/masklinn/xls2txt |
max_upload_size | |
id | 180304 |
size | 43,480 |
xls2txt
and xsl2csv
allow converting spreadsheet files to text for
compatibility with terminals and command-line utilities (e.g. diff or
less). Despite the name, they should work with both excel (xls, xlsx
or xlsb) and OpenDocument (ods) files.
The two executables provided by this package broadly work the same
way, returning one line per row separated by a unix newline (\n
) and
quoting field values if necessary, they differ only in their default
field (cell) separator:
xls2txt
separates cells with a TAB characterxls2csv
uses a comma (,
)The tab separator seems like a better default for readability and compatibility with various unix utilities.
Both utilities have the same parameter and options, differing only by their default:
PATH
is a mandatory path to a spreadsheet file to convert.
--sheet
(-s
) is the sheet to convert. By default, the first
sheet is converted.
sheet
can be either the name of a sheet, or its position in the
workbook (starting at 1, though 0 will be treated as 1).
--record-separator
(-r
) is the separator used between
sheet rows, it defaults to a unix newline for both utilities.
--field-separator
(f
) is the separator used between
sheet cells, it defaults to a TAB character for xsl2txt
and a
COMMA for xls2csv
.
--formula
specifies the formula display mode:
cached-value
), formulas are not displayed, if a
formula cell has a cached value that is displayed, otherwise the
cell is emptyif-empty
will show the cached value if there is one, but will
show the formula if there isn't onealways
will always display the formula of a formula cell, never
the cached valuethe converted data is written to stdout
error messages can be written to stdout, including on success e.g. if an error occurs while parsing formulas and the formula mode is not the default, an error will be signaled then the formula mode will be reset to default
returns 0
if the entire conversion succeeded, 1
otherwise:
This allows viewing textual diffs of spreadsheet files using git log
or git diff
rather than get an unhelpful "binary files differ":
create a $HOME/.gitattributes
file, or set an arbitrary file as
the attributes file (git config --global core.attributesFile <filename>
)
in that file, associate the relevant spreadsheet extensions with the proper category (hunk-header):
*.ods diff=spreadsheet
*.xls diff=spreadsheet
*.xlsx diff=spreadsheet
*.xlsb diff=spreadsheet
set xls2txt
(or xls2csv
), possibly configured as you desire, as
the diff text converter:
git config --global diff.spreadsheet.textconv xls2txt
Add support for displaying formulas