簡體   English   中英

使用Excel在F#中繪圖

[英]Plotting in F# using Excel

能夠使用答案在F#中將數據添加到Excel電子表格中

.NET 4.0的F#和Excel集成(Visual Studio 2010 Beta 1)

我發現自己無法弄清楚如何使用插入的數據來創建圖表(使用F#以Excel編程方式)。 如何才能做到這一點?

我正在使用Excel 2007(Office 12組件)和F#2.0,如果這是相關的。

我有一個例子,展示了如何在真實世界的功能編程書中做到這一點。 第13章首先下載一些數據,然后將它們添加到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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM