All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ExcelPlotter.py
Go to the documentation of this file.
1 import win32com.client
2 import gaudiextra
3 
4 class Excel:
5  def __init__(self):
6  self.ex = win32com.client.Dispatch('Excel.Application')
7  self.wb = self.ex.Workbooks.Add()
8  self.ws = self.wb.WorkSheets.Add()
9  self.ws.Name = 'HistoData'
10  self.ch = self.wb.Charts.Add()
11  self.ch.Name = 'HistoPlot'
12  def plot(self, h):
13  self.ex.Visible = 0
14  heights = h.heights()
15  nbin = len(heights)
16  xmin, xmax = h.edges()
17  for i in range(nbin) :
18  self.ws.Cells(i+1,1).value = heights[i]
19  self.ws.Cells(i+1,2).value = xmin + i*(xmax-xmin)/nbin
20  self.ch.SetSourceData(self.ws.Range(self.ws.Cells(1,1), self.ws.Cells(nbin+1,1)))
21  self.ch.HasTitle = 1
22  self.ch.ChartTitle.Text = h.title()
23  self.ser = self.ch.SeriesCollection(1)
24  self.ser.XValues = self.ws.Range(self.ws.Cells(1,2), self.ws.Cells(nbin+1,2))
25  self.ex.Visible = 1
26 
27 global excel
28 excel = Excel()
29 
30 
31 
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range form arbitrary container
Definition: NamedRange.h:130
def __init__(self)
Definition: ExcelPlotter.py:5
def plot(self, h)
Definition: ExcelPlotter.py:12