📜 ⬆️ ⬇️

Perl & MS Excel

There was a need to create beautiful reports in MS Excel? So do this with perl! :)

So let's get started:

use OLE; // Win32::OLE
my $excel = CreateObject OLE 'Excel.Application' or die $!; // Excel
$excel->{'Visible'} = 1; // Excel , ,
my $workbook = $excel -> Workbooks -> Add(); //
$workbook -> ActiveSheet -> Range("A1")-> {'Value'} = sprintf(""); // A1 «»
$workbook -> ActiveSheet -> Columns -> AutoFit; // –
$workbook -> SaveAs("$file"); //
$workbook -> ActiveSheet -> PrintOut; // -
$excel -> Quit; // Excel


Voila!
')
Well, and some useful things in the end:

$workbook -> ActiveSheet -> Range("A1")-> Font -> {FontStyle} = 'Bold'; //
$workbook -> ActiveSheet -> Range("A1")-> {HorizontalAlignment} = 3; // –
$workbook -> ActiveSheet -> Range("A1")-> Borders -> {LineStyle} = 1; //
$workbook -> ActiveSheet -> Range("A1")-> Interior -> {ColorIndex} = 15; //
$workbook -> ActiveSheet -> Range("A1")-> EntireRow -> Delete; //
$workbook -> ActiveSheet -> Range("A1:A10") -> Merge; //

Source: https://habr.com/ru/post/57294/


All Articles