Sami.S
Sami.S

Reputation: 267

How to insert a chart with data non-contiguous in Excel using API office.js?

I know is it possible with Excel doing something like this :

'---------------------
Set a1 = Range(Cells(10, 1), Cells(20, 1))
Set a2 = Range(Cells(10, 8), Cells(20, 8))
u = Union(a1, a2).Address
'-------------
Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets('Feuil1').Range(u), PlotBy:=xlColumns

But Is it possible with the office.js API ?

Thanks in advance ;-)

Upvotes: 1

Views: 199

Answers (1)

Michael Zlatkovsky
Michael Zlatkovsky

Reputation: 8670

Due to varying degrees of support for creating such charts on Excel desktop vs. Online vs. iOS vs. Mac, the APIs currently do not expose the ability to bind to a non-contiguous range. If you have noncontiguous data, your best bet would be to copy it to another sheet (which you can hide if you want) in a contiguous fashion, in the order in which you want the data displayed. And then create a chart off of that (just like in regular Excel, the chart can be on a different sheet than its data range).

Upvotes: 1

Related Questions