def addNewSeries(self, NChart=None, NSheet=None, xColumn=1, yColumn=2): # use 1-based indeces for NChart and NSheet if NChart == None: ch = self.chartList[-1] else: ch = self.chartList[NChart-1] if NSheet == None: sh = self.sheetList[-1] else: sh = self.sheetList[NSheet-1] series = ch.SeriesCollection().NewSeries() Ncolumns, Nrows = xlChFormula.getNcolumnsNrowsFromRange( sh.UsedRange.AddressLocal ) L = self.formula.makeColRange(NColumn=xColumn, fromRow=2, toRow=Nrows) rx = sh.Range(L) series.XValues = rx L = self.formula.makeColRange(NColumn=yColumn, fromRow=2, toRow=Nrows) ry = sh.Range(L) series.Values = ry cL = self.formula.makeColLocation( NColumn=yColumn, NRow=1) r = sh.Range(cL) series.Name = r
def addNewSeries(self, NChart=None, NSheet=None, xColumn=1, yColumn=2): # use 1-based indeces for NChart and NSheet if NChart == None: ch = self.chartList[-1] else: ch = self.chartList[NChart - 1] if NSheet == None: sh = self.sheetList[-1] else: sh = self.sheetList[NSheet - 1] series = ch.SeriesCollection().NewSeries() Ncolumns, Nrows = xlChFormula.getNcolumnsNrowsFromRange( sh.UsedRange.AddressLocal) L = self.formula.makeColRange(NColumn=xColumn, fromRow=2, toRow=Nrows) rx = sh.Range(L) series.XValues = rx L = self.formula.makeColRange(NColumn=yColumn, fromRow=2, toRow=Nrows) ry = sh.Range(L) series.Values = ry cL = self.formula.makeColLocation(NColumn=yColumn, NRow=1) r = sh.Range(cL) series.Name = r
def changeSeriesOnChart(self, NChart=1, NSeries=1, NSheet=1, xColumn=1, yColumn=2): # use 1-based indeces for NChart and NSheet sh = self.sheetList[NSheet-1] ch = self.chartList[NChart-1] Ncolumns, Nrows = xlChFormula.getNcolumnsNrowsFromRange( sh.UsedRange.AddressLocal ) L = self.formula.makeColRange(NColumn=xColumn, fromRow=2, toRow=Nrows) rx = sh.Range(L) ch.XYGroups(1).SeriesCollection(NSeries).XValues = rx L = self.formula.makeColRange(NColumn=yColumn, fromRow=2, toRow=Nrows) ry = sh.Range(L) ch.XYGroups(1).SeriesCollection(NSeries).Values = ry cL = self.formula.makeColLocation( NColumn=yColumn, NRow=1) r = sh.Range(cL) ch.SeriesCollection(NSeries).Name = r
def addNewSeriesToCurrentSheetChart(self, xColumn=1, yColumn=2): sh = self.xlSheet ch = self.chart series = ch.SeriesCollection().NewSeries() Ncolumns, Nrows = xlChFormula.getNcolumnsNrowsFromRange( sh.UsedRange.AddressLocal ) L = self.formula.makeColRange(NColumn=xColumn, fromRow=2, toRow=Nrows) rx = sh.Range(L) series.XValues = rx L = self.formula.makeColRange(NColumn=yColumn, fromRow=2, toRow=Nrows) ry = sh.Range(L) series.Values = ry cL = self.formula.makeColLocation( NColumn=yColumn, NRow=1) r = sh.Range(cL) series.Name = r
def initFromXLSFile(self): '''initialize from existing XLS file. (file has already been opened and assigned to self.xlApp)''' #print "now in initFromXLSFile" self.xlSheet = None self.chart = None for ns in range(1, self.xlApp.Sheets.Count + 1): #sheets use 1-based index try: #print "starting loop",ns if self.xlApp.Sheets(ns).Type == constants.xlWorksheet: Ncolumns, Nrows = xlChFormula.getNcolumnsNrowsFromRange(\ self.xlApp.Sheets(ns).UsedRange.AddressLocal) # check that sheet has info in it and should be added to sheet list if Ncolumns > 0 and Nrows > 0: self.xlSheet = self.xlApp.Sheets(ns) self.sheetList.append(self.xlSheet) self.nRows = Nrows self.nColumns = Ncolumns # chart and sheet lists are mapped self.chartNColumns.append(self.nColumns) self.chartNRows.append(self.nRows) #print "calling getChartSheetNumberUsingSheetData" nc = self.getChartSheetNumberUsingSheetData( self.xlApp.Sheets(ns).Name) #print "found chart for sheet",ns,"chart=",nc #print "chart type =",self.xlApp.Sheets(nc).ChartType," =? ",constants.xlXYScatterLines if ( nc > 0 ): ###/// and (self.xlApp.Sheets(nc).ChartType==constants.xlXYScatterLines): #print "assigning chart for sheet",ns,"chart=",nc self.chart = self.xlApp.Sheets(nc) self.chartList.append(self.chart) #else: # self.chartList.append( None ) except: pass
def initFromXLSFile(self): '''initialize from existing XLS file. (file has already been opened and assigned to self.xlApp)''' #print "now in initFromXLSFile" self.xlSheet = None self.chart = None for ns in range(1, self.xlApp.Sheets.Count+1): #sheets use 1-based index try: #print "starting loop",ns if self.xlApp.Sheets(ns).Type == constants.xlWorksheet: Ncolumns, Nrows = xlChFormula.getNcolumnsNrowsFromRange(\ self.xlApp.Sheets(ns).UsedRange.AddressLocal) # check that sheet has info in it and should be added to sheet list if Ncolumns>0 and Nrows>0: self.xlSheet = self.xlApp.Sheets(ns) self.sheetList.append( self.xlSheet ) self.nRows = Nrows self.nColumns = Ncolumns # chart and sheet lists are mapped self.chartNColumns.append( self.nColumns ) self.chartNRows.append( self.nRows ) #print "calling getChartSheetNumberUsingSheetData" nc = self.getChartSheetNumberUsingSheetData(self.xlApp.Sheets(ns).Name) #print "found chart for sheet",ns,"chart=",nc #print "chart type =",self.xlApp.Sheets(nc).ChartType," =? ",constants.xlXYScatterLines if (nc>0): ###/// and (self.xlApp.Sheets(nc).ChartType==constants.xlXYScatterLines): #print "assigning chart for sheet",ns,"chart=",nc self.chart = self.xlApp.Sheets(nc) self.chartList.append( self.chart ) #else: # self.chartList.append( None ) except: pass