Plotting in F # using Excel

The ability to add data to an Excel spreadsheet from F # using the answer to

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

I cannot figure out how to use the data inserted to create the chart (programmatically in Excel using F #). How can I do that?

I use Excel 2007 (Office 12 component) and F # 2.0, if that matters.

+3
source share
1 answer

I have an example that shows how to do this in a real-world functional programming book. Chapter 13 first loads some data, then adds it to Excel and creates a graph.

  • .

() , , , , :

// 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
+5

Source: https://habr.com/ru/post/1752373/


All Articles