Creating Charts in Excel with pyExcelerator.ExcelMagic
Greetings, I'm new to python and am in the process of writing a script to parse some CSV data, spread it across multiple Excel worksheets and then generate charts. I searched the internet to find some place where I could look up a HOWTO doc/recipe to do that using either pyExcelerator or win32com.client. Could someone point me in the right direction? I'm at the stage where the spreadsheet and associated data worksheets are ready. The chart is created (with win32com.client). I need to know how I can use win32com.client to actually generate some data based on the contents of a particular work sheet. >>> from win32com.client import * >>> xl = win32com.client.Dispatch("Excel.Application") >>> wb = xl.Workbooks.open("C:\scripts\dummytest.xls") >>> xl.Visible = 1 >>> ws = wb.Worksheets(1) >>> ws.Range('$A1:$D1').Value = ['NAME', 'PLACE', 'RANK', 'PRICE'] >>> ws.Range('$A2:$D2').Value = ['Foo', 'Fooland', 1, 100] >>> ws.Range('$A3:$D3').Value = ['Bar', 'Barland', 2, 75] >>> ws.Range('$A4:$D4').Value = ['Stuff', 'Stuffland', 3, 50] >>> wb.Save() >>> wb.Charts.Add() >>> wc1 = wb.Charts(1) At this point, I'm lost -- I couldn't find any lucid docs to indicate what can be done to populate the chart from the worksheet "ws". Any help would be greatly appreciated. TIA -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating Charts in Excel with pyExcelerator.ExcelMagic
Gentlemen, Thanks for your responses. I also found some additional threads on this newsgroup that gave me insight into how to use the MS Excel com objects (or whatever they are called)... So I used this: xl = win32com.client.Dispatch("Excel.Application") wb = xl.Workbooks.Open(outfile01) prodws = wb.Worksheets(1) wc_prod = wb.Charts.Add() wc_prod.ChartWizard(Source=prodws.Range("b1", "g30"), Gallery=11, Format=5, CategoryLabels=3, SeriesLabels=3, PlotBy=None, Title="Prod" ) Does a pretty decent job of creating charts (we can change the chart type by changing the Gallery and Format values) So I use pyExcelerator to generate the workbook with various worksheets and then use win32com.client to generate the charts. -- http://mail.python.org/mailman/listinfo/python-list
Re: py2exe for programs with excel COM objects
[EMAIL PROTECTED] wrote: > Is it possible to create a executable of a python program that refers > to Excel COM objects with the help of py2exe. Hi, I just used py2exe to create an executable. If you want to deliver the package with an installation wizard, just use Inno Setup tools (http://www.jrsoftware.org/). Look at an example of how to create the setup.py script and it's a no-brainer from that point on. -- http://mail.python.org/mailman/listinfo/python-list