Answered by:
How to display Excel in ASP.Net ?

Question
-
User-775831949 posted
Please share
I have an Excel dashboard XLSX file and wish to display it on ASP.Net.
Is this possible without use of Sharepoint ?
Thanks
Saturday, August 1, 2015 3:16 AM
Answers
-
User-271186128 posted
Hi hkbeer,
have an Excel dashboard XLSX file and wish to display it on ASP.Net.As for this issue, you could import the Excel File data into DataTable or DataSet, then displayed in ASP.Net GridView control. For more details, you could refer to this link:
Or, you could also try to read or import Excel Sheet Data into ASP.Net GridView Control using OLEDB and ADO.Net. Like this:
http://www.aspsnippets.com/Articles/Read-and-Import-Excel-Sheet-into-ASP.Net-GridView-Control.aspx
http://www.aspsnippets.com/Articles/Read-and-Import-Excel-Sheet-using-ADO.Net-and-C.aspx
Besides, you could also using SqlBulkCopy to import Excel SpreadSheet data into SQL Server in ASP.Net, then query the database and bind to GridVew.
Best Regards,
Dillion- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, August 3, 2015 5:03 AM
All replies
-
User-1923420989 posted
Saturday, August 1, 2015 3:56 AM -
User-959762932 posted
Only to view the file in asp.net we can use gridview control and bind that one.
if (file1.HasFile) { string data = null; bool b = false; string excelPath = Server.MapPath("~/filefolder/") + Path.GetFileName(file1.PostedFile.FileName); file1.SaveAs(excelPath); string conString = string.Empty; string extension = Path.GetExtension(file1.PostedFile.FileName); switch (extension) { case ".xls": //Excel 97-03 conString = ConfigurationManager.ConnectionStrings["Excel03ConString"].ConnectionString; break; case ".xlsx": //Excel 07 or higher conString = ConfigurationManager.ConnectionStrings["Excel07ConString"].ConnectionString; break; } conString = string.Format(conString, excelPath); using (OleDbConnection excel_con = new OleDbConnection(conString)) { excel_con.Open(); string sheet1 = excel_con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null).Rows[0]["TABLE_NAME"].ToString(); DataTable dtExcelData = new DataTable(); using (OleDbDataAdapter oda = new OleDbDataAdapter("SELECT * FROM [" + sheet1 + "]", excel_con)) { oda.Fill(dtExcelData); } excel_con.Close(); gridview1.DataSource = dtExcelData; gridview1.DataBind(); }
In web config file:
<add name="Excel03ConString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0};Extended Properties='Excel 8.0;HDR=YES'"/> <add name="Excel07ConString" connectionString="Provider=Microsoft.ACE.OLEDB.12.0; Data Source={0};Extended Properties='Excel 8.0;HDR=YES'"/>
Saturday, August 1, 2015 6:57 AM -
User-271186128 posted
Hi hkbeer,
have an Excel dashboard XLSX file and wish to display it on ASP.Net.As for this issue, you could import the Excel File data into DataTable or DataSet, then displayed in ASP.Net GridView control. For more details, you could refer to this link:
Or, you could also try to read or import Excel Sheet Data into ASP.Net GridView Control using OLEDB and ADO.Net. Like this:
http://www.aspsnippets.com/Articles/Read-and-Import-Excel-Sheet-into-ASP.Net-GridView-Control.aspx
http://www.aspsnippets.com/Articles/Read-and-Import-Excel-Sheet-using-ADO.Net-and-C.aspx
Besides, you could also using SqlBulkCopy to import Excel SpreadSheet data into SQL Server in ASP.Net, then query the database and bind to GridVew.
Best Regards,
Dillion- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, August 3, 2015 5:03 AM