473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Calling external data by a function to create pivot table in excel format

This program works.
upuse Win32::OLE;
Expand|Select|Wrap|Line Numbers
  1. # Start Excel and make it visible
  2. $xlApp = Win32::OLE->new('Excel.Application');
  3. $xlApp->{Visible} = 1;
  4.  
  5. # Create a new workbook
  6. $xlBook = $xlApp->Workbooks->Add;
  7.  
  8. # Our data that we will add to the workbook...
  9. $mydata = [["Item",     "Category", "Price"], 
  10.            ["Nails",    "Hardware",  "5.25"],
  11.            ["Shirt",    "Clothing", "23.00"],
  12.            ["Hammer",   "Hardware", "16.25"],
  13.            ["Sandwich", "Food",      "5.00"],
  14.            ["Pants",    "Clothing", "31.00"],
  15.            ["Drinks",   "Food",      "2.25"]];
  16.  
  17. # Write all the data at once...
  18. $rng = $xlBook->ActiveSheet->Range("A1:C7");
  19. $rng->{Value} = $mydata;
  20.  
  21. # Create a PivotTable for the data...
  22. $tbl = $xlBook->ActiveSheet->PivotTableWizard(1, $rng, "", "MyPivotTable");
  23.  
  24. # Set pivot fields...
  25. $tbl->AddFields("Category", "Item");
  26. $tbl->PivotFields("Price")->{Orientation} = 4; # 4=xlDataField
  27.  
  28. # Create a chart too...
  29. $chart = $xlBook->Charts->Add;
  30. $chart->SetSourceData($rng, 2);
  31. $chart->{ChartType} = 70; # 3D-pie chart
  32. $chart->Location(2, "Sheet4");
  33.  
  34. # Wait for user input...
  35. print "Press <return> to continue...";
  36. $x = <STDIN>;
  37.  
  38. # Clean up
  39. $xlBook->{Saved} = 1;
  40. $xlApp->Quit;
  41. $xlBook = 0;
  42. $xlApp = 0;
  43.  
  44. print "All done.";
  45.  
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.47,15.15,15.23,35671454
01/21/2010,15.19,15.30,14.22,14.25,69930509
01/22/2010,14.18,14.18,13.33,13.40,84478420
01/25/2010,13.76,13.85,13.31,13.39,44190316
256 deep represent Date Open High Low Volume columns
Mar 11 '12 #1
0 1505

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Putz Ronald | last post by:
Hy! I am trying to convert a win Oracle application to solaris! We have use external c functions which I have ibncluded in a shared object. See the makefile below: OBJECTS = definitions.o...
4
by: Ajay | last post by:
Hello all, I used to display reports in Excel earlier on my website. Now the client has requested that he would like see reports in Pivot table on the web . The backend is Sql2000. Can you please...
1
by: peter | last post by:
Dear all, I have an existing query called 'A', but I want it to view in Pivot Table. What I do is : - Double click the query and choose Pivot Table view. - I make some changes by adding some...
14
by: Lee | last post by:
I have a xml file, here is sample part: <?xml version="1.0" encoding="UTF-8"?> <ProducsList> <Product id="1"> <SpecList> <Spec> <SpecLabel>Height</SpecLabel> <SpecValue>10</SpecValue>...
1
by: huntress | last post by:
I am trying to create pivot tables using VBA in Access 2003. Is this possible? How do I go about it?
1
benchpolo
by: benchpolo | last post by:
I have data extracted from Access db to Excel with a pivot table. Somehow, I am having issues with the pivot table were it doesnt update the totals. For example, the first extract i did in Access...
32
by: redman08 | last post by:
I have produced an Excel (2007) worksheet, with which I want to create a Pivot Table. This would all be done from a module run on an Access 2007 database. Please can anyone supply some simple...
1
by: mizukage | last post by:
Ok, so lets say I have a .csv file called flags.csv, with the following data (Column 1)- (Column 2) Country- Colour Australia- Red Australia- Red Australia- Red America - Red UK - Red...
6
by: nicolenwn | last post by:
Hi everyone(: I'm having trouble creating pivot tables using macros. First i tried recording it then running the exact same thing. It worked fine the first time but a week later when i tried...
0
by: sarah2855 | last post by:
Hello, I would like to insert a pivot table in an access report.I was able to create a pivot table chart in Query -> pivot table view but I don't know how to incorporate that in reports. Is this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.