This program works.
upuse Win32::OLE;
except my data is a function call from a external server,and it is : http://127.0.0.1:16239/req?GetHistory(Stock symbol,01/20/2010,1/26/2012,1D,YES) with output as
OK
01/20/2010,15.42,15.4 7,15.15,15.23,3 5671454
01/21/2010,15.19,15.3 0,14.22,14.25,6 9930509
01/22/2010,14.18,14.1 8,13.33,13.40,8 4478420
01/25/2010,13.76,13.8 5,13.31,13.39,4 4190316
256 deep represent Date Open High Low Volume columns
upuse Win32::OLE;
Code:
# Start Excel and make it visible
$xlApp = Win32::OLE->new('Excel.Application');
$xlApp->{Visible} = 1;
# Create a new workbook
$xlBook = $xlApp->Workbooks->Add;
# Our data that we will add to the workbook...
$mydata = [["Item", "Category", "Price"],
["Nails", "Hardware", "5.25"],
["Shirt", "Clothing", "23.00"],
["Hammer", "Hardware", "16.25"],
["Sandwich", "Food", "5.00"],
["Pants", "Clothing", "31.00"],
["Drinks", "Food", "2.25"]];
# Write all the data at once...
$rng = $xlBook->ActiveSheet->Range("A1:C7");
$rng->{Value} = $mydata;
# Create a PivotTable for the data...
$tbl = $xlBook->ActiveSheet->PivotTableWizard(1, $rng, "", "MyPivotTable");
# Set pivot fields...
$tbl->AddFields("Category", "Item");
$tbl->PivotFields("Price")->{Orientation} = 4; # 4=xlDataField
# Create a chart too...
$chart = $xlBook->Charts->Add;
$chart->SetSourceData($rng, 2);
$chart->{ChartType} = 70; # 3D-pie chart
$chart->Location(2, "Sheet4");
# Wait for user input...
print "Press <return> to continue...";
$x = <STDIN>;
# Clean up
$xlBook->{Saved} = 1;
$xlApp->Quit;
$xlBook = 0;
$xlApp = 0;
print "All done.";
OK
01/20/2010,15.42,15.4 7,15.15,15.23,3 5671454
01/21/2010,15.19,15.3 0,14.22,14.25,6 9930509
01/22/2010,14.18,14.1 8,13.33,13.40,8 4478420
01/25/2010,13.76,13.8 5,13.31,13.39,4 4190316
256 deep represent Date Open High Low Volume columns