slloyd has asked for the wisdom of the Perl Monks concerning the following question:
Note: I found the Excel constants at http://www.convert-files.com/SII/Convert-XLS/English/WebHelp/command_line_manual/file_type_constants/rhid_excel_conversion_file_type_constants.htm so I tried -1 as the FileFormat but it did not work.
Update: If this is not possible, is there a way to save the entire xlx file as PDF?
#!c:\perl\bin use strict; use Win32::OLE; use Win32::OLE qw(in with); use Win32::OLE::Variant; use Win32::OLE::Const 'Microsoft Excel'; my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application'); $Excel->{'Visible'} = 1; #0 is hidden, 1 is visible $Excel->{DisplayAlerts}=1; #0 is hide alerts # Open File and Worksheet my $Book = $Excel->Workbooks->Open('C:\temp\XLS\test.xls'); my $cnt=0; foreach my $Worksheet (in $Book->{Worksheets}){ $cnt++; my $filename="C:\temp\XLS\test2\_$cnt.pdf"; print "saving $filename\n"; #HOW DO I SAVE THIS worksheet as a PDF or a PNG??? $Worksheet->SaveAs({Filename =>$filename,FileFormat => -1}); } # Save as Excel $Book->Close(); $Excel->Quit(); exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Save Excel worksheets as PDF
by CountZero (Bishop) on Feb 26, 2010 at 19:08 UTC | |
by almut (Canon) on Feb 26, 2010 at 19:23 UTC | |
by CountZero (Bishop) on Feb 27, 2010 at 07:37 UTC | |
|
Re: Save Excel worksheets as PDF
by planetscape (Chancellor) on Feb 27, 2010 at 21:09 UTC | |
by Corion (Patriarch) on Feb 27, 2010 at 21:12 UTC | |
by planetscape (Chancellor) on Feb 27, 2010 at 21:19 UTC |