http://www.perlmonks.org?node_id=422177


in reply to Spreadsheet::ParseExcel vs alternative Cell Handler


When you supply your own cell handler you don't need to iterate through the workbook sheet by sheet and cell by cell.

The iteration will occur automatically when you call the Parse() method. As such you don't need any of the code below:

my $oBook = $oExcel->Parse($file);

I can post a more complete example if you define a little more clearly what you are trying to do. It looks like you are trying to extract the cells in the first column of the first worksheet and print them as in a Html format but perhaps you can go into a little more detail.

--
John.

Replies are listed 'Best First'.
Re^2: Spreadsheet::ParseExcel vs alternative Cell Handler
by Andre_br (Pilgrim) on Jan 15, 2005 at 16:51 UTC
    Hey John,

    Thanks for the help. What I am trying to do is just use Perl to convert a .xls table to a tab-delimited .txt file. This last one will suffer many inspections and processings - because of that I need the conversion, in order to avoid the weight of the .xls file all along the data analysis. At the end, having appended a last column "1" or "0" to each line of the tsv .txt, according to if itīs data is approved or not, the "1" lines are imported to the mysql database. Then, I use your Spreadsheet writter to give back the user the processed file with the error messages (when you implement the writte_comment theyīll go that way).

    Well, thatīs the whole story. For the conversion, using only your cell handler, I would have to identify wich line and wich column is each cell from, in order to record it with a "\t" after or a "\n" if it's the last column of that row. It seems the code I was using before would manage to do that, if I put it inside your cell-handler, wouldnīt it? Or there is another way of doing it? Or is there another simpler way?

    Thanks a lot, John.

    André

      PS: Itīs important that I split the conversion and the processing. I know I could do the inspection right away, but to split the process and give some information to the user like "file uploaded and converted" is important in this case, before I do the inspection (wish will happen at his command).