L
leob
I need to retrieve the the active worksheet of an Excel file using
OleDbConnection.
With the following code, I can retrieve the list worksheets, but I can't
find a way to get to the active one.
string sExcelFileName = @"c:\excelfiles\ExcelFile.xls";
string sConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ sExcelFileName + ";Extended Properties=\"Excel 8.0;HDR=No;IMEX=1;\"";
OleDbConnection ExcelConnection = new OleDbConnection(sConnectionString);
ExcelConnection.Open();
DataTable excelDataTable =
ExcelConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[]
{null, null});
foreach (DataRow row in excelDataTable.Rows)
{
string sWorksheetName = row["TABLE_NAME"].ToString();
MessageBox.Show(sWorksheetName);
}
ExcelConnection.Close();
More generally, I need to access the content of the active worksheet of an
excel file submitted to an ASP .NET web application.
Any way of doing it without using directly server-side automation of Office?
Thanks
OleDbConnection.
With the following code, I can retrieve the list worksheets, but I can't
find a way to get to the active one.
string sExcelFileName = @"c:\excelfiles\ExcelFile.xls";
string sConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ sExcelFileName + ";Extended Properties=\"Excel 8.0;HDR=No;IMEX=1;\"";
OleDbConnection ExcelConnection = new OleDbConnection(sConnectionString);
ExcelConnection.Open();
DataTable excelDataTable =
ExcelConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[]
{null, null});
foreach (DataRow row in excelDataTable.Rows)
{
string sWorksheetName = row["TABLE_NAME"].ToString();
MessageBox.Show(sWorksheetName);
}
ExcelConnection.Close();
More generally, I need to access the content of the active worksheet of an
excel file submitted to an ASP .NET web application.
Any way of doing it without using directly server-side automation of Office?
Thanks