| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# 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