Gaudi Framework, version v20r4

Generated: 8 Jan 2009

ExcelPlotter.py

Go to the documentation of this file.
00001 import win32com.client
00002 import gaudiextra
00003 
00004 class Excel:
00005         def __init__(self):
00006                 self.ex = win32com.client.Dispatch('Excel.Application')
00007                 self.wb = self.ex.Workbooks.Add()
00008                 self.ws = self.wb.WorkSheets.Add()
00009                 self.ws.Name = 'HistoData'
00010                 self.ch = self.wb.Charts.Add()
00011                 self.ch.Name = 'HistoPlot'
00012         def plot(self, h):
00013                 self.ex.Visible = 0
00014                 heights = h.heights()
00015                 nbin = len(heights)
00016                 xmin, xmax = h.edges()
00017                 for i in range(nbin) :
00018                         self.ws.Cells(i+1,1).value = heights[i]
00019                         self.ws.Cells(i+1,2).value = xmin + i*(xmax-xmin)/nbin 
00020                 self.ch.SetSourceData(self.ws.Range(self.ws.Cells(1,1), self.ws.Cells(nbin+1,1)))
00021                 self.ch.HasTitle = 1
00022                 self.ch.ChartTitle.Text = h.title()
00023                 self.ser = self.ch.SeriesCollection(1)
00024                 self.ser.XValues = self.ws.Range(self.ws.Cells(1,2), self.ws.Cells(nbin+1,2))
00025                 self.ex.Visible = 1
00026 
00027 global excel
00028 excel = Excel()
00029 
00030 
00031 

Generated at Thu Jan 8 17:44:22 2009 for Gaudi Framework, version v20r4 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004