in reply to Re^3: Merging 2 xlsx files
in thread Merging 2 xlsx files

.

Replies are listed 'Best First'.
Re^5: Merging 2 xlsx files
by Tux (Canon) on Sep 08, 2017 at 10:35 UTC

    Start with replacing Spreadsheet::XLSX (which used to be fine) with Spreadsheet::ParseXLSX, which has a richer feature set, is compatible with Spreadsheet::ParseExcel, well maintained and well supported.

    Then as suggested, read their docs to see what you have to change in your existing code to make it work.

    Then, once everything works again (hopefully), you can post existing working strict-safe code here to ask for help on the last bits and pieces.

    We all have struggled with new modules in the beginning. The questions we ask cause the maintainers to write better docs (most of the time), so newcommers do not have to ask again: the answer is most likely in the docs.

    As perl - and the CPAN modules - are OpenSource, you can also follow the links provided by the Monks and "steal" (and learn) from the code and examples already available. I'd suggest having a look at csv2xlsx and replace the bits that require a different parser. You can steal from xlscat and many other tools for that.

    Enjoy your journey


    Enjoy, Have FUN! H.Merijn
Re^5: Merging 2 xlsx files
by thanos1983 (Parson) on Sep 08, 2017 at 00:52 UTC
Re^5: Merging 2 xlsx files
by afoken (Chancellor) on Sep 08, 2017 at 06:58 UTC
    I need to use Excel::Writer::XLSX for writer and Spreadsheet::XLSX for reader, but I didn't know how to use it

    Start by reading the documentation for that modules.

    I tried with the below script, but this one uses the old xls application, my files are xlsx.

    Quick and dirty way: Convert XLSX to XLS, then use the old script, finally convert XLS back to XLSX.

    I can feel that you will ask how to convert between XLS and XLSX. Well, let me give you a hint: Modern Excel can read and write old excel formats.

    I appreciate your help.

    I think you misspelled that. Did you mean "Write code for me"?

    Perlmonks is not a code writing service. Use the quick and dirty hack, or start using your own brain. Yes, learning Perl takes time, like learning any other language.

    You have an old script that uses the "wrong" modules. I know that at least some of the Spreadsheet::* modules intentionally have very similar, if not identical, APIs for handling XLS and XLSX. So start by simply replacing the XLS module names with the XLSX module names in the script. Start the script, look at the errors it gives you and try to fix them. You will very likely need the documentation for the XLS and XLSX modules, and you have to read the documentation.

    When you reach the point where you can no longer find a way to fix an error, post the modified code and the error messages in this thread.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^5: Merging 2 xlsx files
by poj (Abbot) on Sep 08, 2017 at 09:39 UTC
    move all detailed formatting including Comments

    I don't think Spreadsheet::XLSX can extract comments. Do you have access to a windows machine with Excel ? If so, consider using Win32::OLE.

    poj