How to open excel in asp.net???
ASP.NET
2
Posts
2
Posters
1
Views
1
Watching
-
Hi, How to open excisiting excel document in asp.net??
Yours, KaNNaN ----------------------------------------------------------------- "Success is When Ur Signature Becomes An Autograph"
You can read excel into a dataset and then can dispay it easily using grid view of whatever control you prefer.
int workSheetNumber = 0;
OleDbConnection ExcelConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FilePathWithName + ";Extended Properties=Excel 8.0;");
OleDbCommand ExcelCommand = new OleDbCommand(); ExcelCommand.Connection = ExcelConnection; OleDbDataAdapter ExcelAdapter = new OleDbDataAdapter(ExcelCommand); ExcelConnection.Open(); System.Data.DataTable ExcelSheets = ExcelConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object\[\] { null, null, null, "TABLE" }); string SpreadSheetName = "\[" + ExcelSheets.Rows\[workSheetNumber\]\["TABLE\_NAME"\].ToString() + "\]"; DataSet ExcelDataSet = new DataSet(); ExcelCommand.CommandText = @"SELECT \* FROM " + SpreadSheetName; ExcelAdapter.Fill(ExcelDataSet);