Accessing Excel worksheet names via ASP.Net 2.0

G

Guest

Hello,
I want to receive the worksheet names for random Excel sheets, the below
mentioned solution works for most excel sheet but with the most important one
I get too many excel sheets in this format

'WS1$' ''this one works
'WS1$'print_tables
'WS2$'Z_XX_XXX
'WS2$'Print_area

Where does the stuff after the $' come frome and how can I avoid this and
just receive the actual worksheet names ('WS1$') and at best in the order the
occur in the document and not alphabetically.

Thanks very much for your support and I hope i phrased the question in an
understandable fashion
Jörg


Code to get the Excel schema
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=Book1.xls;Extended Properties=""Excel 8.0;HDR=YES;""";
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
connection.Open();
worksheets = connection.GetSchema("Tables");
}
 
G

Guest

Does this help?
Sub ShtNames()
n1 = ActiveWorkbook.Sheets.Count
ReDim ShtNames(n1)
For i1 = 1 To n1
ShtNames(i1) = Worksheets(i1).Name
Next
End Sub
 
G

Guest

The ActiveWorkbook Object is only referring to the currently open Excel
Sheet, or how can I declare on eExcel Workbook as active?
I need to access those excel documents on a server (without Excel...)
Still thank you very much for your answer
Jörg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top