All Projects → MarkPflug → Sylvan.Data.Excel

MarkPflug / Sylvan.Data.Excel

Licence: MIT license
The fastest .NET library for reading Excel data files.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to Sylvan.Data.Excel

Readxl
Read excel files (.xls and .xlsx) into R 🖇
Stars: ✭ 585 (+800%)
Mutual labels:  excel, xlsx, xls
Xresloader
跨平台Excel导表工具(Excel=>protobuf/msgpack/lua/javascript/json/xml)
Stars: ✭ 161 (+147.69%)
Mutual labels:  excel, xlsx, xls
Sheetjs
📗 SheetJS Community Edition -- Spreadsheet Data Toolkit
Stars: ✭ 28,479 (+43713.85%)
Mutual labels:  excel, xlsx, xls
Easyexcel
快速、简单避免OOM的java处理Excel工具
Stars: ✭ 22,133 (+33950.77%)
Mutual labels:  excel, xlsx, xls
Documentbuilder
ONLYOFFICE Document Builder is powerful text, spreadsheet, presentation and PDF generating tool
Stars: ✭ 61 (-6.15%)
Mutual labels:  excel, xlsx, xls
Docjure
Read and write Office documents from Clojure
Stars: ✭ 510 (+684.62%)
Mutual labels:  excel, xlsx, xls
Phpspreadsheet
A pure PHP library for reading and writing spreadsheet files
Stars: ✭ 10,627 (+16249.23%)
Mutual labels:  excel, xlsx, xls
exoffice
Library to parse common excel formats (xls, xlsx, csv)
Stars: ✭ 31 (-52.31%)
Mutual labels:  excel, xlsx, xls
Desktopeditors
An office suite that combines text, spreadsheet and presentation editors allowing to create, view and edit local documents
Stars: ✭ 1,008 (+1450.77%)
Mutual labels:  excel, xlsx, xls
Pyexcel
Single API for reading, manipulating and writing data in csv, ods, xls, xlsx and xlsm files
Stars: ✭ 902 (+1287.69%)
Mutual labels:  excel, xlsx, xls
Npoi.mapper
Use this tool to import or export data with Excel file. The tool is a convention based mapper between strong typed object and Excel data via NPOI.
Stars: ✭ 348 (+435.38%)
Mutual labels:  excel, xlsx, xls
Excelmapper
Map POCO objects to Excel files
Stars: ✭ 166 (+155.38%)
Mutual labels:  excel, xlsx, xls
J
❌ Multi-format spreadsheet CLI (now merged in http://github.com/sheetjs/js-xlsx )
Stars: ✭ 343 (+427.69%)
Mutual labels:  excel, xlsx, xls
Test files
📚 SheetJS Test Files (XLS/XLSX/XLSB and other spreadsheet formats)
Stars: ✭ 150 (+130.77%)
Mutual labels:  excel, xlsx, xls
dbd
dbd is a database prototyping tool that enables data analysts and engineers to quickly load and transform data in SQL databases.
Stars: ✭ 30 (-53.85%)
Mutual labels:  excel, xlsx, xls
Rows
A common, beautiful interface to tabular data, no matter the format
Stars: ✭ 739 (+1036.92%)
Mutual labels:  excel, xlsx, xls
spreadsheet
Yii2 extension for export to Excel
Stars: ✭ 79 (+21.54%)
Mutual labels:  excel, xlsx, xls
spark-hadoopoffice-ds
A Spark datasource for the HadoopOffice library
Stars: ✭ 36 (-44.62%)
Mutual labels:  excel, xlsx, xls
Tableexport
The simple, easy-to-implement library to export HTML tables to xlsx, xls, csv, and txt files.
Stars: ✭ 781 (+1101.54%)
Mutual labels:  excel, xlsx, xls
Myexcel
MyExcel, a new way to operate excel!
Stars: ✭ 1,198 (+1743.08%)
Mutual labels:  excel, xlsx, xls

Sylvan.Data.Excel

A cross-platform .NET library for reading and writing Excel data files. The most commonly used formats: .xlsx, .xlsb and .xls, are supported for reading, while only .xlsx is supported for writing.

ExcelDataReader provides readonly, row by row, forward-only access to the data. It provides a familiar API via DbDataReader, which is ideal for accessing rectangular, tabular data sets. It exposes a single, unified API for accessing all supported file formats.

ExcelDataWriter supports writing data from a DbDataReader to an Excel worksheet in .xlsx format. ExcelDataWriter can only write a new Excel, it cannot be used to edit or append to existing files.

The library is a purely managed implementation with no external dependencies.

This library is currently the fastest and lowest allocating library for reading Excel data files in the .NET ecosystem, for all supported formats.

If you encounter any issues while using this library, please report an issue in the github repository. Be aware that I will be unlikely to investigate any issue unless an example file can be provided reproducing the issue.

Installing

Sylvan.Data.Excel Nuget Package

Install-Package Sylvan.Data.Excel

ExcelDataReader

ExcelDataReader derives from DbDataReader, so it exposes an API that should be familiar for anyone who has worked with ADO.NET before. The field accessors allow reading data in an efficient, strongly-typed manner: GetString, GetInt32, GetDateTime, GetBoolean, etc.

The GetExcelDataType method allows inspecting the native Excel data type of a cell, which may vary from row to row. FieldCount, returns the number of columns in the header row, and doesn't change while processing each row in a sheet. RowFieldCount returns the number of fields in the current row, which might vary from row to row, and can be used to access cells in a "jagged", non-rectangular file.

Reading Raw Data

The ExcelDataReader provides a forward only, row by row access to the data in a worksheet. It allows iterating over sheets using the NextResult() method, and iterating over rows using the Read() method. Fields are accessed using standard accessors, most commonly GetString(). GetString() is designed to not throw an exception, except in the case that a cell contains a formula error.

using Sylvan.Data.Excel;

// ExcelDataReader derives from System.Data.DbDataReader
// The Create method can open .xls, .xlsx or .xlsb files.
using ExcelDataReader edr = ExcelDataReader.Create("data.xls");

do 
{
	var sheetName = edr.WorksheetName;
	// enumerate rows in current sheet.
	while(edr.Read())
	{
		// iterate cells in row.
		// can use edr.RowFieldCount when sheet contains jagged, non-rectangular data
		for(int i = 0; i < edr.FieldCount; i++)
		{
			var value = edr.GetString(i);
		}
		// Can use other strongly-typed accessors
		// bool flag = edr.GetBoolean(0);
		// DateTime date = edr.GetDateTime(1);
		// decimal amt = edr.GetDecimal(2);
	}
	// iterates sheets
} while(edr.NextResult());

Bind Excel data to objects using Sylvan.Data

The Sylvan.Data library includes a general-purpose data binder that can bind a DbDataReader to objects. This can be used to easily read an Excel file as a series of strongly typed objects.

using Sylvan.Data;
using Sylvan.Data.Excel;

using var edr = ExcelDataReader.Create("data.xlsx");
foreach (MyRecord item in edr.GetRecords<MyRecord>())
{
    Console.WriteLine($"{item.Name} {item.Quantity}");
}

class MyRecord
{
    public int Id { get; set; }
    public string Name { get; set; }
    public int? Quantity { get; set; }
    public DateTime Date { get; set; }
}

Converting Excel data to CSV(s)

The Sylvan.Data.Csv library can be used to convert Excel worksheet data to CSV.

using Sylvan.Data.Excel;
using Sylvan.Data.Csv;

using var edr = ExcelDataReader.Create("data.xlsx");

do 
{
	var sheetName = edr.WorksheetName;
	using CsvDataWriter cdw = CsvDataWriter.Create("data-" + sheetName + ".csv")
	cdw.Write(edr);
} while(edr.NextResult());

ExcelDataWriter

The ExcelDataWriter type is used to create Excel workbooks and write DbDataReader data as worksheets.

// *critical* to dispose (using) ExcelDataWriter.
using var edw = ExcelDataWriter.Create("data.xlsx");
DbDataReader dr;
dr = GetQueryResults("UserReport");
edw.Write(dr, "UserReport");
dr = GetQueryResults("SecurityAudit");
edw.Write(dr, "SecurityAudit");
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].