Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^5: XLSX read and dump

by talexb (Canon)
on Jan 18, 2012 at 19:48 UTC ( #948611=note: print w/ replies, xml ) Need Help??


in reply to Re^4: XLSX read and dump
in thread XLSX read and dump

    The test.xlsx file isn't in a zip file. I thought it was going to create a new file called test.xlsx, but didn't.

Sorry -- confusion. The 'new' in this context doesn't mean it's going to *create* a file. It's creating a new context in order read one of your files that already exists.

Next, I'm not sure

my $excel = Spreadsheet::XLSX -> new ('test.xlsx');
is correct. I would have expected
my $excel = Spreadsheet::XLSX->new ('test.xlsx');
to be better. Does your script produce any warnings when you run it?

You need to get to the point where you're able to open a file in your current directory before we can proceed.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds


Comment on Re^5: XLSX read and dump
Select or Download Code
Re^6: XLSX read and dump
by chirp84 (Novice) on Jan 18, 2012 at 20:11 UTC
    Okay, the data file I renamed had the wrong extension. I had .xls, after I changed to .xlsx the script ran. All the data from excel printed into my terminal window in the format below:
    ( 1 , 1 ) => -230 ( 1 , 2 ) => -201.25 ( 1 , 3 ) => -172.5 ( 1 , 4 ) => -143.75
    and so on... Also, I changed the code to reflect exactly what the Spreadsheet::XLSX synopsis shows because my actual row and column names were causing errors. Now the question is: How can I print just the cells I want to a separate file?
        How can I print just the cells I want to a separate file?

      What does the documentation say?

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re^6: XLSX read and dump
by tobyink (Abbot) on Jan 18, 2012 at 21:30 UTC

    Next, I'm not sure

    my $excel = Spreadsheet::XLSX -> new ('test.xlsx');

    is correct.

    It's not a common way of laying out code, but adding arbitrary whitespace between tokens in Perl is rarely disallowed. Whitespace is only really needed between tokens if they'd look like another token if the whitespace was missing.

    For example, given:

    use 5.010; my @foo = split /\|/, q {foo|bar|bar}; foreach my $x (@foo) { say $x; }

    ... there are only actually two pieces of required whitespace: between "use" and "5.010", and between "foreach" and "my". The code runs perfectly well if you strip out the rest of the whitespace:

    use 5.010;my@foo=split/\|/,q{foo|bar|bar};foreach my$x(@foo){say$x}

    ... though most people would consider the former to be more readable.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2014-07-30 05:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls