Hi guys
I'm currently working on an ASP.NET application that reads in Excel data to a DataSet, is there any way of telling how many worksheets the Excel doc contains?
Currently I'm using this code
I have to use a string array for each of the excel sheets but I dont really want to have to hardcode this for each excel doc I usePHP Code:for(int i=0; i<this.excelSheets.Length; i++)
{
string strCommand = "SELECT * FROM ["+
this.excelSheets[i]+
"$]";
string strConnection =@"Provider=Microsoft.Jet.OLEDB.4.0;"+
@" Data Source="+this.filePath+this.fileName+
@";"+
@" Extended Properties=""Excel 8.0;"+
@" HDR=YES;""";
OleDbDataAdapter objDataAdapter = new OleDbDataAdapter(strCommand,strConnection);
this.dataSetName.Tables.Add(this.excelSheets[i]);
objDataAdapter.Fill(dataSetName,this.excelSheets[i]);
}
Hope this makes sense
Any help would be much appreciated
Thanks in advance
Tez




Bookmarks