Форум сайта python.su
Уважаемое сообщество, эксперты!
Прошу помощи.
Исходные данные
1. Win64, Python2.7, Tomcat7
2. В Tomcat7 сконфигурировано для Python CGI scripts
http://lekshmideepu.blogspot.com/2013/03/configure-tomcat-7-to-run-python-cgi.html
3. Все прекрасно работает
http://localhost:8080/pychart/cgi-bin/hello.py
4. Есть скрипт Chart1.py. Его положил в папку tomcat70/webapps/pychart/cgi-bin/
import sys import os, commands from win32com.client import Dispatch xlApp = Dispatch("Excel.Application") # show excel xlApp.Visible=False # create an XLS file # load a pre-created excel sheet sheet_file_name = r"c:\1\22.xls" try: xlBook = xlApp.Workbooks.Open(sheet_file_name, 0, False, 2) except Exception as inst: print "Content-type: text/html\n\n"; print(sheet_file_name) print(inst) xlSheet = xlBook.Sheets(1) xlSheet.Name = "My Chart" xlSheet.Cells(1,1).Value="My Chart" xlSheet.Cells(2,1).Value="2" xlSheet.Cells(3,1).Value="8" xlSheet.Cells(4,1).Value="32" xlSheet.Cells(5,1).Value="50" xlSheet.Cells(5,2).Value="100" xlSheet.Cells(6,1).Value="25" xlSheet.Cells(6,2).Value="50" xlSheet.Cells(7,1).Value="25" xlSheet.Cells(7,2).Value="50" xlSheet.Cells(8,1).Value="25" xlSheet.Cells(8,2).Value="50" xlSheet.Cells(9,1).Value="25" xlSheet.Cells(9,2).Value="50" chart1=xlSheet.ChartObjects(1) chartObject = xlSheet.ChartObjects(1) chart1 = chartObject.chart chart1.SetSourceData(Source=xlSheet.Range("A1:B9")) chart1.HasTitle = True chart1.ChartTitle.Characters.Text ="title 11111" chart1.Type = -4102 chart1.Elevation = 15 chart1.ChartArea.Fill.ForeColor.SchemeColor = 49 chart1.ChartArea.Fill.BackColor.SchemeColor = 20 chart1.ChartTitle.Font.Size = 24 chart1.ChartTitle.Font.ColorIndex = 2 xlBook.Close(SaveChanges=1) xlApp.Quit() del xlApp
Отредактировано u000022 (Июнь 11, 2013 21:40:49)
Офлайн