Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to change the Xvalues in excel chart using Interop. Following is what I am using. But it is not recognising Range.

Can anybody help me solve this?

C#
chartPage.SetSourceData Range("A2:A4"), xlColumns
chartPage.SeriesCollection(1).XValues = Range("B2:B4");


It is not accepting Range, everywhere I am finding same answer.

Thank you.
Posted

1 solution

I've hit this before and got around it like this...

Change your using statement to give it an alias, for example ...
C#
using xl = Microsoft.Office.Interop.Excel;

Then use this alias when referring to Range, for example ...
C#
chartPage.SeriesCollection(1).XValues = xl.Range("B2:B4");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900