Description
This is a library for importing Excel spreadsheets into SQL Server tables. In a nutshell, use the `ExcelLoader` class and call one of the `Save` overloads accepting a filename or `Stream`. Customize with ability to add custom columns, removing whitespace and non-printing characters.
Excel2SqlServer alternatives and similar packages
Based on the "ORM" category.
Alternatively, view Excel2SqlServer alternatives based on common mentions on social networks and blogs.
-
TypeORM
Data-Mapper ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, WebSQL databases. Works in Node.js and Browser. -
Entity Framework
Object-relational mapper that enables .NET developers to work with relational data using domain-specific objects -
FreeSql
FreeSql is the ORM in .NetCore, .NetFramework, And Xamarin. It supports Mysql, Postgresql, SqlServer, Oracle, Sqlite, Odbc, 达梦, And MsAccess. -
Fluent NHibernate
Fluent, XML-less, compile safe, automated, convention-based mappings for NHibernate. -
LINQ to DB
The fastest LINQ database access library offering a simple, light, fast, and type-safe layer between your POCO objects and your database. -
Dapper Extensions
Small library that complements Dapper by adding basic CRUD operations (Get, Insert, Update, Delete) for your POCOs -
Entity Framework 6
Object-relational mapper that enables .NET developers to work with relational data using domain-specific objects -
NPoco
Simple microORM that maps the results of a query onto a POCO object. Based on Schotime's branch of PetaPoco -
SmartSql
SmartSql = MyBatis + Cache(Memory | Redis)+ ZooKeeper + R / W Splitting + Dynamic Repository .... -
MicroOrm.Dapper.Repositories
Repository for CRUD operations -
SQLProvider
A general F# SQL database erasing type provider, supporting LINQ queries, schema exploration, individuals, CRUD operations and much more besides. -
MongoDB Repository pattern implementation
Repository abstraction layer on top of Official MongoDB C# driver -
DbExtensions
Data-access framework with a strong focus on query composition, granularity and code aesthetics. -
JsonFlatFileDataStore
Simple JSON flat file data store with support for typed and dynamic data. -
NReco.Data
Lightweight provider-independent DAL for .NET Core: abstract query, SQL command builder, CRUD operations, object mapping.. -
MongoFramework
An "Entity Framework"-like interface for MongoDB -
MicroLite ORM
MicroLite ORM is a micro Object Relational Mapper for the .NET framework. It is designed to be easy to use, extensible and testable. -
Linq.Expression.Optimizer
System.Linq.Expression expressions optimizer. -
EntityFramework.DatabaseMigrator
EntityFramework.DatabaseMigrator is a WinForms utility to help manage Entity Framework 6.0+ migrations. -
Entity Framework Core
Object-relational mapper that enables .NET developers to work with relational data using domain-specific objects -
LLBLGen Pro
Entity Modeling solution for Entity Framework, NHibernate, Linq to SQL and its own ORM framework: LLBLGen Pro Runtime Framework. [$][Free Lite version]
Pixel-Perfect Multi-Platform Applications with C# and XAML
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of Excel2SqlServer or a related project?
README
This is a library for importing Excel spreadsheets into SQL Server tables using Excel Data Reader.
Nuget package: Excel2SqlServer
In a nutshell, use the ExcelLoader class and call one of the SaveAsync
overloads. You can use a local filename or a stream as input. Here's a simple example that loads a single table from a local file:
using (var cn = GetConnection())
{
var loader = new ExcelLoader();
await loader.SaveAsync("MyFile.xlsx", cn, "dbo", "MyTable");
}
This will save an Excel file called MyFile.xlsx
to a database table dbo.MyTable
. The table is created if it doesn't exist. Note also there is an int identity(1,1)
column created called Id
if it doesn't already exist in the spreadsheet.
If a spreadsheet has multiple sheets and you want to import all the sheets into multiple tables, omit the schema and table name from the SaveAsync
call. ExcelLoader
will use the sheet names in the spreadsheet to build the table names. If you need to customize the table names, you can pass a Dictionary<string, ObjectName>
where the key represents the sheet name, and the ObjectName
is the schema + object of the resulting table.
By default, data is always appended to existing data. You can pass an optional Options object to customize the load behavior. For example:
using (var stream = await blob.OpenReadAsync())
{
using (var cn = GetConnection())
{
var loader = new ExcelLoader();
int rows = await loader.SaveAsync(stream, cn, "dbo", "MyTable", new Options()
{
TruncateFirst = true,
AutoTrimStrings = true,
RemoveNonPrintingChars = true,
CustomColumns = new string[]
{
"[IsProcessed] bit NOT NULL DEFAULT (0)",
"[DateUploaded] datetime NOT NULL DEFAULT getdate()"
}
});
}
}
This will append some extra columns to the table when it's created IsProcessed
and DateUploaded
.
An encoding error you might see
Note, if you see an error like this...
...try adding this line before you use ExcelLoader
:
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Reference
- Task CreateTableAsync (string fileName, SqlConnection connection, string schemaName, string tableName, [ IEnumerable customColumns ])
- Task CreateTableAsync (Stream stream, SqlConnection connection, string schemaName, string tableName, [ IEnumerable customColumns ])
- Task<int> SaveAsync (string fileName, SqlConnection connection, [ Dictionary tableNames ], [ Options options ])
- Task<int> SaveAsync (string fileName, SqlConnection connection, string schemaName, string tableName, [ Options options ])
- Task<int> SaveAsync (Stream stream, SqlConnection connection, [ Dictionary tableNames ], [ Options options ])
- Task<int> SaveAsync (Stream stream, SqlConnection connection, string schemaName, string tableName, [ Options options ])
- Task<DataSet> ReadAsync (string fileName)
- Task<DataSet> ReadAsync (Stream stream)