G
Guest
Hello,
I am using OLEDB to access Excel, and what I have read you can access Named
Ranges but I am having trouble doing so. The following are lines of code
I've tried in my C# program to access Named ranges but don't work. Is the
something else I need to do?
string sqlCommand = "Select * From [sheet1!DataExtract$]";
string sqlCommand = "Select * From [sheet1!$DataExtract$]";
string sqlCommand = "Select * From [DataExtract$]";
I can access my Excel Spreadsheet like this, string sqlCommand = "Select *
From [Sheet1$]"; WITHOUT any troubles. However, when I do the Select
statement it returns extra rows that are blank because it doesn't know which
cell was last used. If I can access the Named Range I can eliminate this
issue, but I don't if C# or OLEDB is preventing me from accessing the Named
Range. The following is the error it gives me for the 3 scenarios I tried:
"'sheet1!DataExtract$' is not a valid name. Make sure that it does not
include invalid characters or punctuation and that it is not too long."
"'sheet1!$DataExtract$' is not a valid name. Make sure that it does not
include invalid characters or punctuation and that it is not too long."
"'DataExtract$' is not a valid name. Make sure that it does not include
invalid characters or punctuation and that it is not too long."
I have verified the spelling is correct and that the Named Range exists, and
I still get this error message. Has anyone encounter this before? If so,
how did you fix it?
Thanks,
I am using OLEDB to access Excel, and what I have read you can access Named
Ranges but I am having trouble doing so. The following are lines of code
I've tried in my C# program to access Named ranges but don't work. Is the
something else I need to do?
string sqlCommand = "Select * From [sheet1!DataExtract$]";
string sqlCommand = "Select * From [sheet1!$DataExtract$]";
string sqlCommand = "Select * From [DataExtract$]";
I can access my Excel Spreadsheet like this, string sqlCommand = "Select *
From [Sheet1$]"; WITHOUT any troubles. However, when I do the Select
statement it returns extra rows that are blank because it doesn't know which
cell was last used. If I can access the Named Range I can eliminate this
issue, but I don't if C# or OLEDB is preventing me from accessing the Named
Range. The following is the error it gives me for the 3 scenarios I tried:
"'sheet1!DataExtract$' is not a valid name. Make sure that it does not
include invalid characters or punctuation and that it is not too long."
"'sheet1!$DataExtract$' is not a valid name. Make sure that it does not
include invalid characters or punctuation and that it is not too long."
"'DataExtract$' is not a valid name. Make sure that it does not include
invalid characters or punctuation and that it is not too long."
I have verified the spelling is correct and that the Named Range exists, and
I still get this error message. Has anyone encounter this before? If so,
how did you fix it?
Thanks,