Question Locked

Batch Convert xls to pdf

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi Everyone

I really hope someone can help with this. I have approximately 1700 excel workbooks. Each workbook has a chart in one of the worksheets. I need to make a pdf of each chart (only the chart) and have the pdf file saved with a unique file name (numbers). I was thinking I could do this using a perl script but I need some direction/advice.

Thanks for any help you can provide.

Chris

3 replies

by mdhealy

I very much doubt there's a pure Perl solution to this, getting DATA out of a Excel file is pretty simple with the appropriate Perl modules but the GRAPHICS are another matter!

So I think you're gonna have to use an actual spreadsheet application to do this, using OLE or something similar to control the application from Perl. It can be done, but if you are not familiar with OLE then you'll need to do some reading. Here are starting points for Perl and OLE:

http://books.google.com/books?id=PoRQcHwiLcUC&pg=PA682&lpg=PA682&dq=oreilly+ole+automation&source=bl&ots=JaGnSLRGop&sig=ooIzrzbAGM6YM8aoWLZIBYAPX7M&hl=en&ei=k0vEScr5OsuMtge4qpzJCg&sa=X&oi=book_result&resnum=2&ct=result

http://www.perl.com/pub/a/2005/04/21/win32ole.html

There ARE hooks by which Perl running on a Windows box can call Excel (see here for instance http://www.ngbdigital.com/perl_ole_excel.html) and for the printing you can install the drivers for just about any PostScript printer (use one of those that come with Windows as you do not need the physical printer for this), print to file instead of to the actual printer, then use GhostScript to make a PDF from the PostScript output.

Alternatively, you can use the open source Open Office suite at www.openoffice.org which has its own API or under Windows you can use OLE just like any other application. Open Office has native ability to make a PDF so hacking a PostScript driver and converting to PDF with GhostScript won't be needed.

Advantages of the Open Office solution are first that it's cross-platform and second that because Open Office has built-in ability to make a PDF that part will be simpler.

Main advantage of the Excel solution is better compatibility, Open Office tries very hard but is "99 and 44/100 percent Microsoft compatible" because they had to reverse-engineer and exceedingly complicated file format for which Redmond has always refused to provide documentation. Downsides of the Excel solution are first that it will only work on platforms for which MS Office is available (Windows and Mac), second that Excel doesn't have built-in PDF creation so third-party tools are needed for that.

by peterpatrickgo

besides the script, you could also try other PDF converters which could batch convert your XLS files into PDF format.

This discussion is closed to new replies.