codeice / linqtoexcel

Automatically exported from code.google.com/p/linqtoexcel
0 stars 0 forks source link

Worksheet name containing spaces throws error after WorkSheetRange call. #83

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a worksheet with spaces in the name.  I used: "Work Sheet With Spaces 
In Name"
2. Open the worksheet.
3. var subSheet = eSheet.WorksheetRange("A1",...);
4. var x = subSheet.First();  // Causes confusing error: 

'Work Sheet With Spaces In Name' is not a valid worksheet name. Valid worksheet 
names are: 'Work Sheet With Spaces In Name'

What is the expected output? What do you see instead?
Expected: no error.  Seeing: error.

What version of the product are you using? On what operating system?
1.7. Windows XP

Please provide any additional information below.

Original issue reported on code.google.com by jkoont...@gmail.com on 8 Mar 2013 at 11:10

GoogleCodeExporter commented 8 years ago
Can you attach the worksheet so I can take a look at it.

Original comment by paulyo...@gmail.com on 8 Apr 2013 at 2:11

GoogleCodeExporter commented 8 years ago
Here is an example of sheet with spaces that gets this error. The code I use is 
as follows:

Dim excel = New ExcelQueryFactory("C:\FileLocation\Jamie_example.xls")
Dim workSheetNames = excel.GetWorksheetNames
Dim headersQuery = From item In excel.WorksheetRangeNoHeader("A1", 
"AT1",workSheetNames(0))

Select item
Return headersQuery

The error I get is:

_message = "'S2 IFRS Report - Interest Rate ' is not a valid worksheet name. 
Valid worksheet names are: 'S2 IFRS Report - Interest Rate '"

The attached file should enable you to reproduce this error

Many thanks for looking at this,

Kind regards,

Jamie

Original comment by Bami...@gmail.com on 25 Jun 2013 at 11:04

Attachments:

GoogleCodeExporter commented 8 years ago
I downloaded the source and modified it to get the error message and the 
generated SQL:

_message = "Error is: 'The Microsoft Jet database engine could not find the 
object 'S2 IFRS Report - Interest Rate $A1:AT1'.  Make sure the object exists 
and that you spell its name and the path name correctly.', 
"sql is: 'SELECT * FROM [S2 IFRS Report - Interest Rate $A1:AT1]'"

Original comment by Bami...@gmail.com on 25 Jun 2013 at 12:33

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
We have found that this bug occurs only with Excel 2003 when the length of the 
sheet name is 31 characters long (the max allowed). If the sheet name is 
reduced to 30 chars then there are no problems. It is therefore possible to 
work around this bug.

Original comment by Bami...@gmail.com on 10 Jul 2013 at 10:37

GoogleCodeExporter commented 8 years ago
Thanks for following up with the solution you found!

Original comment by paulyo...@gmail.com on 10 Jul 2013 at 11:18