分享

VFP控制EXECL制图

 庋藏天下 2013-06-22
VFP控制EXECL制图
PROCEDURE prdConfirmPrintA
 m.xlsExcel=CREATEOBJECT('Excel.Application')
 WITH xlsExcel
        .WorkBooks.Add
        DO prdPrintGeneralStatistic WITH UPPER(fncTran('Statistic of progress')) IN _Splr
  DO prdPieChart     WITH 'A1:'+CHR(64+m.nFld)+LTRIM(STR(RECCOUNT()-1)),'',m.cChartTitle
     DO prdColumnWithDepthChart  WITH 'A1:'+CHR(64+m.nFld)+LTRIM(STR(RECCOUNT()-1)),fncTran('1'),3,m.cChartTitle
     DO prdColumnWithDepthChart  WITH 'A1:'+CHR(64+m.nFld)+LTRIM(STR(RECCOUNT()-1)),fncTran('2'),0,m.cChartTitle
  .Sheets(fncTran('Data')).Select
        .Visible=.T.
    ENDWITH
ENDPROC

柱图代码

PROCEDURE prdColumnWithDepthChart
    PARAMETERS m.cRange,m.cChartName,m.nBarShape,m.cChartTitle
    .Sheets('Sheet2').Select
    .Sheets('Sheet2').Range(m.cRange).Select
    .Charts.Add
    WITH .ActiveChart
     .Name       =fncTran('Column chart')+m.cChartName
        .ChartType      =54
        .Elevation      =20
        .Rotation      =25
        .GapDepth      =0
        .BarShape      =m.nBarShape
        .DepthPercent     =500
        .HeightPercent     =100
        .HasTitle      =.T.
        .HasLegend      =.F.
        .HasDataTable     =.F.
        .RightAngleAxes     =.T.
        .WallsAndGridLines2D   =.T.
        .ChartGroups(1).VaryByCategories=.T.
        .Walls.ClearFormats
        WITH .ChartTitle.Characters
            WITH .Font
                .Size     =18
                .Bold     =.T.
                .Name     ='Arial'
            ENDWITH
            .Text      =m.cChartTitle
        ENDWITH
        WITH .Axes(1).TickLabels
         .Orientation    =30
         .Font.Size     =12
         .Font.Name     ='Arial'
        ENDWITH
        WITH .Axes(2)
         .MajorGridLines.Delete
         .TickLabels.Font.Size  =12
         .TickLabels.Font.Name  ='Arial'
        ENDWITH
        WITH .SeriesCollection(1)
         .ApplyDataLabels
         WITH .DataLabels
          .Orientation   =30
          .Font.Size    =12
          .Font.Name    ='Arial'
         ENDWITH
        ENDWITH
        .PageSetup.CenterHeader   =m.cTitleText
    ENDWITH
ENDPROC

饼图代码

PROCEDURE prdPieChart
    PARAMETERS m.cRange,m.cChartName,m.cChartTitle
    .Sheets('Sheet2').Select
    .Sheets('Sheet2').Range(m.cRange).Select
    .Charts.Add
    WITH .ActiveChart
        .Name     =fncTran('Pie chart')+m.cChartName
        .ChartType    =70
        .HasTitle    =.T.
        .HasLegend    =.F.
        .ApplyDataLabels
        WITH .SeriesCollection(1).DataLabels
            .Type    =5
            .Font.Size   =12
            .Font.Name   ='Arial'
            .NumberFormatLocal ='0.00%'
        ENDWITH
        WITH .PlotArea
            .Border.LineStyle =0
            .Interior.ColorIndex=2
        ENDWITH
        WITH .ChartTitle.Characters
            WITH .Font
                .Size   =18
                .Bold   =.T.
                .Name   ='Arial'
            ENDWITH
            .Text    =m.cChartTitle
        ENDWITH
        .PageSetup.CenterHeader =m.cTitleText
    ENDWITH
ENDPROC

折线图代码

PROCEDURE prdLineChart
    PARAMETERS m.cRange,m.cChartName,m.cChartTitle
    .Sheets('Sheet2').Select
    .Sheets('Sheet2').Range(m.cRange).Select
    .Charts.Add
    WITH .ActiveChart
        .Name        =fncTran('Line chart')+m.cChartName
        .ChartType       =65
        .HasTitle       =.T.
        .HasLegend       =.F.
        .ApplyDataLabels
        WITH .Axes(1)
         .HasMajorGridLines    =.F.
         .HasMinorGridLines    =.F.
         WITH .TickLabels
          .Orientation    =30
          .Font.Size     =12
          .Font.Name     ='Arial'
         ENDWITH
        ENDWITH
        WITH .Axes(2)
         .HasMajorGridLines    =.F.
         .HasMinorGridLines    =.F.
         .TickLabels.Font.Size   =12
         .TickLabels.Font.Name   ='Arial'
        ENDWITH
        WITH .SeriesCollection(1)
         WITH .Border
          .ColorIndex     =3
          .Weight      =3
         ENDWITH
         WITH .DataLabels
          .Border.LineStyle   =-4105
          .Position     =0
             .Font.Size     =12
             .Font.Name     ='Arial'
             .Interior.ColorIndex  =28
             .Shadow      =.T.
            ENDWITH
            .Shadow       =.T.
            .Smooth       =.T.
        ENDWITH
        WITH .PlotArea
            .Border.LineStyle    =0
            .Interior.ColorIndex   =2
        ENDWITH
        WITH .ChartTitle.Characters
         .Text       =UPPER(m.cChartTitle)
            WITH .Font
                .Size      =18
                .Bold      =.T.
                .Name      ='Arial'
            ENDWITH
        ENDWITH
        .PageSetup.CenterHeader    =m.cTitleText
    ENDWITH
ENDPROC 

 

FUNCTION fncTran(m.cLanguage)
    IF    SEEK(ALLTRIM(m.cLanguage),'Lngs','cEnglish') AND !EMPTY(Lngs.cCurrent)
         =SEEK(ALLTRIM(m.cLanguage),'Lngs','cEnglish')
        RETURN   ALLTRIM(Lngs.cCurrent)
    ELSE
         RETURN   ALLTRIM(m.cLanguage)
    ENDIF
ENDFUNC

凡是出现fncTran()的地方你可以用其他文本替代,fncTran是自编语言翻译函数

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多