Is there a free or open source library to read out Excel files (. xlsx) directly from a C# program?
It does not have to be too fancy, simply to choose a worksheet and check out the data as strings. Far, I’ve been utilizing Export to Unicode text function of Excel, and parsing the resulting (tab-delimited) file, but I ‘d like to eliminate the manual action.
The ADO.NET approach is simple and fast, but it has a few quirks which you need to understand, specifically relating to how DataTypes are managed.
How about Excel Data Reader?
I’ve used in it anger, in a production environment, to pull big quantities of data from a range of Excel submits into SQL Server Compact. It works extremely well and it’s rather robust.
Not free, however with the most recent Office there’s a very nice automation.Net API. (there has actually been an API for a long while but was nasty COM) You can do everything you desire/ need in code all while the Office app remains a covert background process.
Recently, partly to get better at LINQ … I’ve been utilizing Excel’s automation API to save the file as XML Spreadsheet and then get process that file utilizing LINQ to XML.
SmartXLS is another stand out spreadsheet element which support most features of excel Charts, formulas engines, and can read/write the excel2007 openxml format.
The.NET part Excel Reader.NET may please your requirement. It’s great enought for checking out XLSX and XLS files.
I advise the FileHelpers Library which is a free-and-easy to use.NET library to import/export data from EXCEL, repaired length or delimited records in strings, files or streams + More.
I understand that people have been making an Excel “extension” for this purpose.
You basically make a button in Excel that says “Export to Program X”, and after that export and send out off the data in a format the program can read.
Excel Plan is an open-source (GPL) component for reading/writing Excel 2007 files. I utilized it on a small project, and the API is uncomplicated. Functions with XLSX just (Excel 200 &), not with XLS.
If you require to expand performance or fix small concerns as I did), the source code also seems easy and well-organized to get around (.
Initially, I tried the ADO.Net (Excel connection string) technique, however it was stuffed with nasty hacks– for circumstances if 2nd row contains a number, it will return ints for all fields in the column listed below and quietly drop any data that does not fit.
, if you require to work just with open XML documents (*.. xslx) you might think about utilizing the Open XML SDK. See Welcome to the Open XML SDK 2.5 for Office for more details.
In case of binary file format you require to utilize any third-party elements that do not required Office/Excel installed on the maker.
If you are developing a solution that runs in a server-side context, you ought to attempt to utilize components that have been made safe for unattended execution. If you utilize an Office application from a server-side solution, the application will lack numerous of the needed capabilities to run successfully.
If MS Office is not installed, you can’t utilize Microsoft Interop libraries. You might desire to look at alternative options to read Excel or Word files. There are lots of free and (paid) C# libraries you might use for this function.