예제 #1
0
 def changeChartType(self, xlChartType, Index=None):
     '''
     Chart: ChangeType
     xlChartType: Integer: use self.xlChartType for reference
     '''
     assert type(xlChartType) == int, '%s must be integer!'
     try:
         _xlChartType = self.pptChart.ChartType  # 返回图表类型
         pptWorkbook, pptWorksheet = self.initChartData()  # 初始化
         if Index:
             self.pptSeriesCollection(Index).ChartType = xlChartType
             print('Shape:%s Chart:%s Index:%s change type from %s to %s!' %
                   (self.pptShape.Name, self.pptChart.Name, Index,
                    MSOPowerpointFunc.funcLookupKey(_xlChartType,
                                                    self.xlChartType),
                    MSOPowerpointFunc.funcLookupKey(xlChartType,
                                                    self.xlChartType)))
         else:
             self.pptChart.ChartType = xlChartType
             print('Shape:%s Chart:%s change type from %s to %s!' %
                   (self.pptShape.Name, self.pptChart.Name,
                    MSOPowerpointFunc.funcLookupKey(_xlChartType,
                                                    self.xlChartType),
                    MSOPowerpointFunc.funcLookupKey(xlChartType,
                                                    self.xlChartType)))
         self.pptChart.Refresh()
         time.sleep(self.seconds)
         pptWorkbook.Close()
         time.sleep(self.seconds)
         return True
     except:
         traceback.print_exc()
         return False
예제 #2
0
 def addShape(self, AutoShapeType=1, Left=0, Top=0, Width=100, Height=20):
     '''
     Shape: add AutoShape
     '''
     try:
         if type(AutoShapeType) is not int:
             AutoShapeType = self.msoAutoShapeType.get(AutoShapeType, None)
         if self.presInfo['SlidesCount'] == 0: self.addSlide()
         if AutoShapeType:
             self.pptShape = self.pptSlide.Shapes.AddShape(
                 Type=AutoShapeType,
                 Left=Left,
                 Top=Top,
                 Width=Width,
                 Height=Height)
             self.setShape()
             print('Shape :%s ShapeType:%s added!' %
                   (self.pptShape.Name,
                    MSOPowerpointFunc.funcLookupKey(AutoShapeType,
                                                    self.msoAutoShapeType)))
             return True
         return False
     except:
         traceback.print_exc()
         return False