SiteMap  | About    

Read Excel file from ASP.NET

The following ASP.NET application read the content of an Excel file using OLEDB. Here we are using OleDbConnection , OleDbDataAdapter and DataSet for doing this operation in an Excel file. First we have to create an OLEDB connection string to connect the Excel file


connStr = "provider=Microsoft.Jet.OLEDB.4.0;Data Source='ExcelFile.xls';Extended Properties=Excel 8.0;";

Data Source='ExcelFile.xls' : we have to specify the Excel file location.

For read the content from an Excel file using ADO.NET , We can use the SELECT command like in SQL Operations.

  MyCommand = New OleDbDataAdapter("select * from [Sheet1$]", MyConnection)


  MyCommand = new OleDbDataAdapter("select * from [Sheet1$]", MyConnection);



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head id="Head1" runat="server">
<title>Untitled Page</title>
	<form id="form1" runat="server">
	<asp:GridView ID="GridView1" runat="server" />
	<asp:Label ID="Label1" runat="server" Text="Message : "></asp:Label>

Click the following links to see full source code

C# Source Code
VB.NET Source Code
default.aspx.vb (C) 2018    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.