我想从数据库里把数据查出来,然后根据查出来的数据生成饼图写进幻灯片!

解决方案 »

  1.   

    应该可以,chart有转为PIC的方法,然后调用PPT对像,应该没有问题吧!
      

  2.   

    我的问题是把从数据库里选出来的数据做成饼图,写进幻灯片!
    flxa给个例子看看!
      

  3.   

    Private Sub Command1_Click()
      If MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2) <> "" And IsNull(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2)) = False Then '该表格有数据
         With MSChart1
            .ChartType = VtChChartType2dPie
            .ColumnCount = 2
            .RowCount = 1
            Dim XXX As Double
            XXX = Val(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2))
            .TitleText = "饼图示例 完成百分比"
            .Column = 1
            .Row = 1
            .Data = XXX
            .ColumnLabel = "完成百分比" & str(XXX) & "%"
            .Column = 2
            .Row = 1
            .Data = 100 - XXX
            .ColumnLabel = "剩余百分比" & str(100 - XXX) & "%"
         End With
      
      
    '     With MSChart1
    '        .ChartType = VtChChartType2dPie
    '        .ColumnCount = 2
    '        .RowCount = 1
    '        Dim XXX As Double
    '        XXX = Val(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2))
    '        .TitleText = "饼图示例 完成百分比"
    '        .Column = 1
    '        .Row = 1
    '        .Data = XXX
    '        .ColumnLabel = "完成百分比" & Str(XXX) & "%"
    '        .Column = 2
    '        .Row = 1
    '        .Data = 100 - XXX
    '        .ColumnLabel = "剩余百分比" & Str(100 - XXX) & "%"
    '     End With
      
      End IfEnd SubPrivate Sub Command2_Click()
      If MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2) <> "" And IsNull(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2)) = False Then '该表格有数据
        With MSChart1
           .ChartType = VtChChartType2dBar
           .ColumnCount = 2
           .RowCount = MSHFlexGrid1.Rows - 1
           .RowCount = 1
           .TitleText = "直方图示例 本旬出口数量与去年同期对比值"
           Dim XXX, XXXX As Double
           For I = 1 To MSHFlexGrid1.Rows - 1
              XXX = Val(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2))
              XXXX = Val(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2))
              .Column = 1
              .Row = 1
              .Data = XXX
              .Column = 2
              .Row = 1
              .Data = XXXX
              .RowLabel = MSHFlexGrid1.TextMatrix(I, 1)
              .RowLabel = ""
           Next I
           .Column = 1
           .ColumnLabel = "本旬出口数量"
           .Column = 2
           .ColumnLabel = "去年同期对比百分数"
        End With
      End If
    End Sub