Assign value to data sheet in Excel : Excel « Win32 « Perl






Assign value to data sheet in Excel

   

use Win32::OLE;

$operand1 = '2';
$operand2 = '2';

$excelobject = Win32::OLE->new('Excel.Sheet');

$excelobject->Cells(1,1)->{Value} = $operand1;
$excelobject->Cells(2,1)->{Value} = $operand2;

$excelobject->Cells(3,1)->{Formula} = '=R1C1 + R2C1';

$sum = $excelobject->Cells(3,1)->{Value};

$excelobject->Quit();
print "According to Microsoft Excel, $operand1 + $operand2 = $sum.\n";

   
    
    
  








Related examples in the same category

1.Use OLE automation to control Excel
2.Use OLE automation to create an Excel chart