代码之家  ›  专栏  ›  技术社区  ›  Muhammad Alkarouri

使用Excel在F#中绘图

  •  3
  • Muhammad Alkarouri  · 技术社区  · 16 年前

    已经能够使用

    F# and Excel integration for .NET 4.0 (Visual Studio 2010 Beta 1)

    我发现自己不知道如何使用插入的数据创建图表(在Excel中使用F#以编程方式)。如何做到这一点?

    我正在使用Excel2007(Office12组件)和F#2.0,如果相关的话。

    1 回复  |  直到 9 年前
        1
  •  5
  •   Tomas Petricek    16 年前

    第十三章 首先下载一些数据,然后将它们添加到Excel并创建一个图表。

    // Add new item to the charts collection
    let chartobjects = (worksheet.ChartObjects() :?> ChartObjects) 
    let chartobject = chartobjects.Add(400.0, 20.0, 550.0, 350.0) 
    
    // Configure the chart using the wizard
    chartobject.Chart.ChartWizard
      (Title = "Area covered by forests",
       Source = worksheet.Range("B2", "E" + endColumn),
       Gallery = XlChartType.xl3DColumn, PlotBy = XlRowCol.xlColumns,
       SeriesLabels = 1, CategoryLabels = 1,
       CategoryTitle = "", ValueTitle = "Forests (mil km^2)")
    
    // Set graphical style of the chart
    chartobject.Chart.ChartStyle <- 5
    
    推荐文章