Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Parse error in Spreadsheet::ParseExcel::Simple

by igelkott (Priest)
on Apr 21, 2008 at 15:39 UTC ( [id://681944]=note: print w/replies, xml ) Need Help??


in reply to Re: Parse error in Spreadsheet::ParseExcel::Simple
in thread Parse error in Spreadsheet::ParseExcel::Simple

accessing the sheets by name rather than index

I tried doing through Spreadsheet::ParseExcel rather than the "simple" version.

I get the sheet names in the right order (not that that is so important) but the contents appear with a different sheet. For example:

Sheet foo contents of bar Sheet bar contents of baz Sheet baz empty

What I want is the data from "foo" (what I expect to be the first sheet). As you suggest, if I could get it by name, all would be saved ... even if the event would be hard to explain.

I was a bit vague regarding the "reappearing data" because it's just too weird. In excel, I deleted the other sheets from the file and found that I could then find my "foo" data on the "foo" sheet (the only one left).

Replies are listed 'Best First'.
Re^3: Parse error in Spreadsheet::ParseExcel::Simple
by roboticus (Chancellor) on Apr 22, 2008 at 17:58 UTC
    igelkott:

    I suspect that it's not a corrupt file, but that the sheets may not be stored in order of appearance on the tab bar. To check it, try adding the method:

    sub sheet_name { shift->{sheet}->{Name}; }

    to the Spreadsheet::ParseExcel::Simple.pm file, then you can print the sheet name associated with the sheet to check it out. Then, of course, let me know what you discover!

    ...roboticus
      roboticus,

      Added your method to Simple.pm and a print $sheet->sheet_name to the script shown in the original post.

      The sheet names appear in the correct order but the contents do not. Specifically, I get:

      name = sheet 1
      contents = sheet 4
      name = sheet 2
      contents = sheet 2
      name = sheet 3
      contents = sheet 3
      name = sheet 4
      contents = empty

      It's the contents of sheet 1 I'm interested in but can't find. This is like the test with Spreadsheet::ParseExcel above but I was a bit vague (inaccurate) there.

      How to solve my immediate issue is one thing but it's of course more interesting to figure out if this has identified a general bug. I'll play with Data::Dumper, etc to see if anything interesting comes up but not sure how far I'll get into the module source code...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://681944]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 06:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found