5 ms·
Calamine: Excel file reader, written in Rust
- faitswulff 9y agoWas there a particular reason that this library was written? The only thing I can glean from the repo is that it seems to be faster than C# alternatives.
- blowski 9y agoI had a project where I had to translate a frequently updated Excel workbook containing lots of complicated formulas into a PHP project. So I parsed each cell and transpiled the Excel stuff into PHP, and the ran the resulting code. The reason was Excel’s lack of an API. The formulas themselves were too complicated for existing solutions, and kept breaking them. I only built what was necessary so it worked out quicker. No idea if that’s the same as the original use case, but it this kind of library looks like it does the same kind of thing on a more general level.
- slededit 9y agoExcel has several APIs: VBA, COM, XLLs, and JS based Agaves.
- masklinn 9y agoIs any of them usable without excel e.g. on Linux?
- pjmlp 9y agoThere is no need to have Excel installed to use the OpenXML libraries. https://github.com/OfficeDev/Open-Xml-Sdk https://github.com/OfficeDev/Open-Xml-Sdk They also support being used on .NET Core.
- blowski 9y agoThe kind of API I was looking for but couldn’t find (in 2014) was “when I change the value of cell A1 to 17, what’s the value of cell C5?” And get the answer within a couple of seconds. There was no supported way to programmatically change the value of a cell and get the calculated result of a different cell, at least not that I could find.
- WalterGR 9y ago(in 2014) Is the situation different in 2017?
- igitur 9y agohttp://github.com/ClosedXML/ClosedXML http://github.com/ClosedXML/ClosedXML is a wrapper around OpenXML and attempts to fill that gap. It has partial support of Excel formula evaluation. Disclaimer: I'm a current ClosedXML contributor.
- slededit 9y agoIts weird to ask for an Excel API that doesn't use Excel. I guess you meant library.
- masklinn 9y agoSomebody needed to read excel files from Rust, possibly not from Windows? That would also be the reason why openpyxl and xlrd exist for Python: http://www.python-excel.org http://www.python-excel.org e.g. importable data using real spreadsheet files is much more reliable than CSV, and easier for clients to generate.
- brunoqc 9y ago> e.g. importable data using real spreadsheet files is much more reliable than CSV, and easier for clients to generate. It can also be more a pita since cells can have different formats.
- alexnewman 9y agoRust doesn’t require a runtime and that’s often helpful
- geocar 9y agoHow neat! Here's a little Excel-file writer in PHP; Excel will read these files, but this library won't: <?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?> <?php echo '<?mso-application progid="Excel.Sheet"?>'; ?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:html="http://www.w3.org/TR/REC-html40"> <Worksheet ss:Name="Sheet1"> <?php $data = array(array(4,5,6),array("dude","whatever","m<om")); ?> <Table> <?php foreach($data as $row): ?> <Row> <?php foreach($row as $cell): ?> <Cell> <Data ss:Type="String"><?= htmlentities($cell) ?></Data> </Cell> <?php endforeach; ?> </Row> <?php endforeach; ?> </Table> </Worksheet> </Workbook> They're "technically" Microsoft Office XML-format[1], and not "Excel files", but users don't tend to be amused by programmers being technically right so I tend not to argue about that sort of thing. I only bring it up here in case someone wants to search for a specification on it. [1]: https://en.wikipedia.org/wiki/Microsoft_Office_XML_formats https://en.wikipedia.org/wiki/Microsoft_Office_XML_formats
- merb 9y agothis is a spreadsheet ml2003 and not supporting it is not a big deal since this format is probably not widely used in the wild. Basically this file should need a .xml file format, but excel will read files with .xls as well (besides that this is not correct). Basically the XLS was/is a binary format and XLSX is the new spreadsheet ml 2007+ syntax that is standardised. (edit: well the good part of the xml-files were that they could be streamed. this is / was huge for data processing and exporting a la csv)
- jontro 9y agoReally nice. What is the recommended mime-type for this format? text/xml?
- geocar 9y agoI use: application/vnd.ms-excel because that's what launches Excel.
- igitur 9y agoWhich C# libraries were used in comparison? The 2 I know of, EPPlus and ClosedXML, do much more than just read cell values, so it's unfair to compare against those. For example the additional complexity of handling styles adds overhead. Disclaimer: I'm a current ClosedXML contributor.
- moomin 9y agoFor me, the gold standard of these libraries is Apache POI and NPOI. Porting to Rust would be perfectly possible, but it would be _a lot_ of work. Until you support that level of functionality, it's pretty much irrelevant what your "performance" is. You can always improve performance by dropping features.
- TAForObvReasons 9y agoPOI doesn't have full format coverage e.g. calamine supported the Excel 2007+ XLSB format but POI only recently started to support it.
- merb 9y agoactually apache poi is extremely slow while reading/writing large excel files. so there might be the need for some libraries to process them fast.
- laacz 9y agoThere was a time I had to read XLS (BIFF formats) in PHP. Poked around, found some libraries (slow as hell), decided to port[1] one of them (python's xlrd). What followed, even though it was almost 1:1 port, was an inevitable loss of huge part of my life, I'll never get back. However, I learned a lot about what a mess that format is. Since then ANY xml format Microsoft uses is godsent. [1]: https://github.com/laacz/xls-reader https://github.com/laacz/xls-reader