perl_new_b:

I should've read the entire thread before posting my last response. If you're just trying to convert the spreadsheets to .CSV files and add some data to the end, then it's really pretty simple. Writing a new cell handler (as described in the section "Reducing the memory usage of Spreadsheet::ParseExcel" of the Spreadsheet::ParseExcel documentation is pretty easy--all you need to do is store the value, not the formatting, etc. That will make the program consume *much* less RAM. (The cell handler is what builds the *huge* data structure containing all the formatting information, the cell value, unformatted value, etc. Also, each cell is an object containing other overhead such as references to the parent structures, miscellaneous information, etc.

It should be as easy as:

#!/usr/bin/perl -w use strict; use Spreadsheet::ParseExcel; # 3D array for the workbook data: # [0]=sheet #, [1]=row, [2]=col my @WBData; my $parser = Spreadsheet::ParseExcel->new( CellHandler => \&cell_handler, NotSetCell => 1 ); my $workbook = $parser->parse('file.xls'); sub cell_handler { my $workbook = $_[0]; my $sheet_index = $_[1]; my $row = $_[2]; my $col = $_[3]; my $cell = $_[4]; # Store *just* the value into our array $WBData[$sheet_index][$row][$col] = $cell->value(); }

Note: this is untested, it's just lifted straight from the example in the previous link with a couple minor edits.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re^7: Append new line in excel sheets by roboticus
in thread Append new line in excel sheets by perl_new_b

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.