in reply to Re^6: Append new line in excel sheets
in thread Append new line in excel sheets
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Append new line in excel sheets
by perl_new_b (Novice) on Jul 23, 2014 at 12:49 UTC | |
by roboticus (Chancellor) on Jul 23, 2014 at 17:09 UTC | |
by perl_new_b (Novice) on Jul 24, 2014 at 05:22 UTC | |
by roboticus (Chancellor) on Aug 02, 2014 at 14:49 UTC | |
by perl_new_b (Novice) on Jul 24, 2014 at 05:28 UTC | |
by roboticus (Chancellor) on Aug 02, 2014 at 14:51 UTC | |
| |
by perl_new_b (Novice) on Jul 23, 2014 at 13:14 UTC |