Keep full precision in numeric cell strings (Fixes #142)
xls_getfcell formatted NUMBER and RK cells with “%lf”, which truncates to six decimal places, so -0.01992329 came back as “-0.019923”. Use 15 significant digits instead, matching Excel’s display and xls2csv.
Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_015XCQNhFQ1xN8e9ECaYHdoE
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
libxls - Read XLS files from C
This is libxls, a C library for reading Excel files in the nasty old binary OLE format, plus a command-line tool for converting XLS to CSV (named, appropriately enough,
xls2csv).After several years of neglect, libxls is under new management as of the 1.5.x series. Head over to releases to get the latest stable version of libxls 1.5, which fixes many security vulnerabilities found in libxls 1.4 and earlier.
Libxls 1.5 also includes new APIs for parsing files stored in memory buffers, and returns errors instead of exiting upon encountering malformed input. If you find a bug, please file it on the GitHub issue tracker.
Changes to libxls since 1.4:
xls_open_buffer)The C API is pretty simple, this will get you started:
The library also includes a CLI tool for converting Excel files to CSV:
The man page for
xls2csvhas more details.Libxls should run fine on both little-endian and big-endian systems, but if not please open an issue.
If you want to hack on the source, you should first familiarize yourself with the Microsoft Excel File Format as well as Compound Document file format (documentation provided by the nice folks at OpenOffice.org).
Installation
If you want a stable version, check out the Releases section, which has copies of everything you’ll find in Sourceforge, and download version 1.5.0 or later.
For full instructions see INSTALL, or here’s the tl;dr:
To install a stable release:
If you’ve cloned the git repository, you’ll need to run this first:
That will generate all the supporting files. It assumes autotools is already installed on the system (and also expects Autoconf Archive to be present).
Language bindings
If C is not your cup of tea, you can make use of libxls in several other languages, including: