views:

486

answers:

2

In order to make some reports i need to parse some excel files. When i try to select records from sheet i get next error: Invalid bracketing of name '1. page$'.

Heres my code:

OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM [1. page$]", connectionString);

I know it will work if i rename sheet to "page" for example, but as i'm not naming these sheets i need to know how to fix this query to work as it is. What sould I do?

A: 

It looks like your sheet name [1. page$] is invalid. This is OK for an Excel sheet name, but not OK in the query. You should not have the "." in your sheet name.

You can't get around the "." problem. It's just not valid when you are running the query.

Stewbob
+1  A: 

SpreadsheetGear for .NET will let you work with Excel files without the limitations imposed by OleDb.

You can see C# and VB samples here and try it yourself by downloading the free trial here.

Disclaimer: I own SpreadsheetGear LLC

Joe Erickson