in reply to Converting Excel to Pdf

If you're on Windows and have Excel installed, the easiest way is to install a PDF printer driver and use Win32::OLE to drive Excel to print to the PDF printer driver.

The alternative approach would be to use OpenOffice.org to do the conversion. You can launch OpenOffice in "server mode" where it listens to a TCP port (8100?) and where you can send commands to it. Potentially, OpenOffice::UNO works for that, but I haven't done that myself.

Another approach could be to use Spreadsheet::ParseExcel or the Excel HTML export or the XLSX export to create a file that you can process form Perl and then use PDF::Template to write the data into a PDF file, but that method will certainly lose fancy formatting and charts.

Replies are listed 'Best First'.
Re^2: Converting Excel to Pdf
by merrymonk (Hermit) on Jun 15, 2009 at 08:20 UTC
    Many thanks for that.
    I do have a PDF printer driver so that using Win32::OLE seems an excellent idea.
    I have looked at the link you sent.
    However, I could not see an obvious way of using this or a reference to printing.
    Therefore any clues about how Win32::OLE can be used will be more than welcome!

      I gave you several links, and all of them mean you will have to do some work yourself. Printing to PDF is easiest done by following the instructions of Use The Macro Recorder, Luke (Re: Using Win32::OLE and Excel - Tips and Tricks), as with any automation of Microsoft Office products. I wish that OpenOffice had the same facility, but as OpenOffice is more oriented towards you wading through the horrendous Java API than towards you getting things done by showing it an example and then parametrizing that example, that'll remain a pipe dream I guess.

        I have just tried using the macro recorder. It gave
        Application.ActivePrinter = "deskPDF on DDM:" ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,""deskPDF on DDM:"",,TRUE +,,FALSE)"
        I have done this before but always struggle partly because I have no experience of VBA.
        I suspect that Application.ActivePrinter becomes something like Applciation->ActivePrinter but I am not sure what should come before this.
        I am not all sure how to change the Execute line.
        Finally, although I did give a file name before I stopped the macro I could not see this in the recorded code.
        I do mind at all do the work it is just the way to go about it is a bit obscure.