I am writing a few codes to manipulate a diagram in an excle file using C #. One of the key requirements is to obtain the XValue property of the SeriesCollection chart. I tried to visit it by index, but it does not work, although I see a list of values ββin the Clock window in Visual Studio. From the Observation window, I noticed that the type s.XValue dynamic {object []} , which I had never seen before, and obj.ToString () is System.Object [*] . The question is, how can I get each value from the XValue property if XValue does NOT support the index.
By the way, searching the Internet, I can find ways to set the range of Excel cells to XValue, but have not found how to get XValue. I really appreciate if anyone can advise.
Excel._Worksheet worksheet = (Excel._Worksheet)book.Worksheets[a];
Excel.ChartObject chartObj = (Excel.ChartObject)worksheet.ChartObjects(1);
if (chartObj != null)
{
Excel.Chart chart = (Excel.Chart)chartObj.Chart;
var s = (Excel.Series)chart.SeriesCollection(1);
object obj = s.XValues;
}
source
share