zeni has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I would like to know how to read an excel sheet row/column-wise when one or more of them are merged? I tried converting the excel sheet to .csv file but merged data do not appear under proper row/column.

What package can i use to do this task?

Replies are listed 'Best First'.
Re: excel sheet to xml
by roboticus (Chancellor) on May 16, 2012 at 10:42 UTC

    zeni:

    The Spreadsheet::ParseExcel package will read the old .xls formatted spreadsheets, and the Spreadsheet::ParseExcel::Cell class contains an is_merged() function you can use to tell whether the cell is merged or not. (I'm not on a Windows box at the moment, so I can't show you what you'd get.) If it's the newer .xlsx format, you can use the Spreadsheet::XLSX module. I've not used this one before, but the docs mention that it populates the same classes as Spreadsheet::ParseExcel, so it should be mostly compatible.

    For merged cell handling, I don't know what's returned exactly, but I'm thinking that if you don't have two adjacent groups of merged cells, you could just use the is_merged() method and use contiguous merged cells as a single cell. Even better would be if is_merged() returned a unique "block number" for each block of merged cells, then you could just use that.

    ...roboticus

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

      i cannot find these newer modules in cpan :(

      cpan> get ParseExcel.pm Warning: Cannot get ParseExcel.pm, don't know what it is. Try the command i /ParseExcel.pm/ to find objects with matching identifiers.

      Pls help. I am new to cpan usage.

        zeni:

        Try "i Spreadsheet::ParseExcel".

        ...roboticus

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