пятница, 1 января 2016 г.

C# parsing Excel-file without installed Excel

Problem:
Parse Excel-file using C#.

Solution must be used in web application on server, so, it must work without installed Excel.

What Helps?

I use Excel Data Reader library

Main idea: with this library you can import excel file into ADO.NET dataset, then you canwork in .NET dataset terms with rows or cols.

Source code

FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read);

//1. Reading from a binary Excel file ('97-2003 format; *.xls)
IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
//...
//2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
//...
//3. DataSet - The result of each spreadsheet will be created in the result.Tables
DataSet result = excelReader.AsDataSet();


Download link

https://exceldatareader.codeplex.com/

See also


ExcelDataReader
http://exceldatareader.codeplex.com/


Work with Excel on C# without installed Microsoft Office
http://it-student.com.ua/c/tips/rabota-s-excel-v-c-bez-ustanovlennogo-microsoft-office.html

NPOI Lib
http://www.leniel.net/2014/01/npoi-2.0-major-features-enhancements-series-of-posts-scheduled.html#sthash.mzVboJsi.dpbs

NPOI - download link and examples
http://npoi.codeplex.com/releases

NPOI examples
http://stackoverflow.com/questions/5855813/npoi-how-to-read-file-using-npoi



Work with Excel through Com Server
http://wladm.narod.ru/C_Sharp/comexcel.html#7

Excel object model from the .NET developer point of view
http://www.ishodniki.ru/art/art_progr/net/474.html


Excel with C#
http://petrachuk.ru/excel-by-csharp/

C# How To Read .xlsx Excel File With 3 Lines of Code
http://www.codeproject.com/Tips/801032/Csharp-How-To-Read-xlsx-Excel-File-With-Lines-of

Excel reading or writing using OpenXML
http://habrahabr.ru/post/203522/

Koogra Excel BIFF/XLSX Reader Library
http://sourceforge.net/projects/koogra/

Комментариев нет:

Отправить комментарий