I want to read Excel Tables 2010 xlsx using NPOI and then export data to DataTables but don't know how to use it. Can anyone show me step by step how to export Excel to Datatable? I have downloaded NPOI.dll, added to reference but don't know what further ...
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
You can accomplish you task by doing this.
}
I edited @Saeb Amini code to allow blank cells.
NPOI is a great and free way to read Excel files, and now in version 2 you can read both XLS and XLSX file types.
Now the following code does the trick, comments are in spanish, sorry for that :-p
The above code assumes the first row of the sheet has the column names. The code also determines the data Type of each cell and tries to convert it to an ADO data type. Blank cells are converted to null.
Hope this helps you and others in the same situation.
On Codeplex website here in Download section there is
example package
- a pack of C# examples. Try it, if you haven't yet.This is simplest example of it -
You can try ToxySpreadsheet in Toxy project - toxy.codeplex.com. ToxySpreadsheet.ToDataSet() is what you want.