You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
|| Win32::OLE->new('Excel.Application', 'Quit');
# Open Excel file
my $Book = $Excel->Workbooks->Open($excel_file);
#Make Excel visible
$Excel->{Visible} = 1;
#___ ADD NEW WORKBOOK
my $Book = $Excel->Workbooks->Add;
my $Sheet = $Book->Worksheets("Sheet1");
$Sheet->Activate;
#Save Excel file
$Excel->{DisplayAlerts}=0; # This turns off the "This file already exists" message.
$Book->Save; #Or $Book->SaveAs("C:\\file_name.xls");
$Book->Close; #or $Excel->Quit;
2. Manipulación de hojas de trabajo.
#Get the active Worksheet
my $Book = $Excel->Activewindow;
my $Sheet = $Book->Activesheet;
#List of Worksheet names
my @list_Sheet = map { $_->{'Name'} } (in $Book->{Worksheets});
#Access a given Worksheet
my $Sheet = $Book->Worksheets($list_Sheet[0]);
#Add new Worksheet
$Book->Worksheets->Add({After => $workbook->Worksheets($workbook->Worksheets->{Count})});
#Change Worksheet Name
$Sheet->{Name} = "Name of Worksheet";
#Freeze Pane
$Excel -> ActiveWindow -> {FreezePanes} = "True";
#Delete Sheet
$Sheet -> Delete;
3. Manipulación de células.
#Edit the value of a cell (2 methods)
$Sheet->Range("A1")->{Value} = 1234;
$Sheet->Cells(1,1)->{Value} = 1234;
#Edit the values in a range of cells
$Sheet->Range("A8:C9")->{Value} = [[ undef, 'Xyzzy', 'Plugh' ],
[ 42, 'Perl', 3.1415 ]];
#Edit the formula in a cell (2 types)
$Sheet->Range("A1")->{Formula} = "=A1*9.81";
$Sheet->Range("A3")->{FormulaR1C1} = "=SUM(R[-2]C:R[-1]C)";
$Sheet->Range("C1")->{FormulaR1C1} = "=SUM(RC[-2]:RC[-1])";
# Sum of rows
# Sum of columns
https://riptutorial.com/es/home 26