The sample demonstrates how to export the data from spreadsheet to datatable.
using System; using System.Data; using System.Windows.Forms; using Spire.Xls; namespace ExcelSheetToDataTable { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Workbook workbook = new Workbook(); workbook.LoadFromFile(@"..\..\parts.xls",ExcelVersion.Version97to2003); //Initialize worksheet Worksheet sheet = workbook.Worksheets[0]; DataTable dataTable = sheet.ExportDataTable(); this.dataGridView1.DataSource = dataTable; } } }
Imports System.Data Imports System.Windows.Forms Imports Spire.Xls Namespace ExcelSheetToDataTable Public Partial Class Form1 Inherits Form Public Sub New() InitializeComponent() End Sub Private Sub button1_Click(sender As Object, e As EventArgs) Dim workbook As New Workbook() workbook.LoadFromFile("..\..\parts.xls", ExcelVersion.Version97to2003) 'Initialize worksheet Dim sheet As Worksheet = workbook.Worksheets(0) Dim dataTable As DataTable = sheet.ExportDataTable() Me.dataGridView1.DataSource = dataTable End Sub End Class End Namespace