Import Data from Excel to Datatable

  • Demo
  • C# source
  • VB.Net source
This demo shows you how to read data from an excel workbook and export data.
No Matter How Big or Small Your Project is,
Any technical question related to our product, contact us at support@e-iceblue.com.
Any question related to the purchase of product, contact us at sales@e-iceblue.com.
If you don't find the demo you want, please contact support@e-iceblue.com for the free customized demo just for you.
using System.Data;
using Spire.Xls;

namespace DemoOnlineCode
{
    class ImportDatafromExceltoDatatable
    {
        public void demoImportDatafromExceltoDatatable(string filePath,string resultFilePath)
        {
            Workbook book = new Workbook();
            book.LoadFromFile(filePath);
            DataTable table = book.Worksheets[0].ExportDataTable();
            Workbook data_book = new Workbook();
            data_book.Worksheets[0].InsertDataTable(table,true,1,1);
            data_book.SaveToFile(resultFilePath,ExcelVersion.Version2010);

        
        }

    }
}
                                                          
Imports System.Data
Imports Spire.XLS

Namespace DemoOnlineCode
    Class ImportDatafromExceltoDatatable
        Public Sub demoImportDatafromExceltoDatatable(filePath As String, resultFilePath As String)
            Dim book As New Workbook()
            book.LoadFromFile(filePath)
            Dim table As DataTable = book.Worksheets(0).ExportDataTable()
            Dim data_book As New Workbook()
            data_book.Worksheets(0).InsertDataTable(table, True, 1, 1)
            data_book.SaveToFile(resultFilePath, ExcelVersion.Version2010)


        End Sub

    End Class
End Namespace