Free Support Forum - aspose.com

Data vertical source

Hi,


In order to make some copies of charts, I need to know if the sources of my charts series are vertical or not. I can’t find this property in the Series object. Could someone help me ?

Example of the code I need to implement (changing “true” by the real value) :

foreach (Series serie in chartToAdd.NSeries)
{
chartCreated.NSeries.Add(serie.Values, true);
chartCreated.NSeries[numChart].Type = serie.Type;
chartCreated.NSeries[numChart].Name = serie.Name;
chartCreated.NSeries[numChart].DataLabels.ShowValue = serie.DataLabels.ShowValue;
chartCreated.NSeries[numChart].DataLabels.ShowPercentage = serie.DataLabels.ShowPercentage;
numChart++;
}

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

You will have to check individual Series object of existing Chart. You can check Series.Values property and decide if your series is vertical or horizontal

For example, if it returns

=Sheet1!$A$1:$A$6

then Series is vertical because column is not changing.

But if it returns

=Sheet1!$B$2:$D$2

then Series is horizontal because row is not changing.

You will have to split and parse the Series.Values property to make this decision.

Thank you for this answer. I had thought to this solution but I hoped an other one :wink: Do you know why this property (“isVertical”) is not available to get ?

Hi,

Thanks for you input and using Aspose.Cells.

I will discuss this issue with the development team and we will analyze it. If it is feasible and causes no major problems, we will implement this property in our future versions.

As a workaround, you can use the following code to find if the Series is vertical or horizontal at your end.

C#


Workbook workbook = new Workbook(filePath);


Worksheet worksheet = workbook.Worksheets[0];


Chart chart = worksheet.Charts[0];


//Get the series range

string seriesRange = chart.NSeries[0].Values;


//Create a range object by removing its sheet part

Range range = worksheet.Cells.CreateRange(seriesRange.Split(new string[] { “!” }, StringSplitOptions.None)[1]);


//Now if the column count is 1, then it is vertical

if (range.ColumnCount == 1 && range.RowCount > 0)

{

Debug.WriteLine(“This series is vertical”);

}


//And if the row count is 1, then it is horizontal

if (range.RowCount == 1 && range.ColumnCount > 0)

{

Debug.WriteLine(“This series is horizontal”);

}

We have logged this issue in our database as a New Feature Request with the issue id: CELLSNET-41189

Once, we will have some fix or update for you, we will let you know asap.

Thanks everybody for the help. I finally use a regular expression to check if data source is vertical or horizontal :


Match match = Regex.Match(serie.Values, @"[A-Za-z0-9]$([A-Z])$[0-9]:$([A-Z])$[0-9]*", RegexOptions.IgnoreCase);
bool areDatasVertical = match.Groups[1].Value.Equals(match.Groups[2].Value);

Hi,

Thanks for your posting and using Aspose.Cells.

That’s great. We also have implemented this feature and deliver it in our next releases.

Once, the fix is available, we will let you know asap.

Hi,

We have fixed this issue.

Please download and try this fix: Aspose.Cells for .NET v7.3.3.4 and let us know your feedback.

The issues you have found earlier (filed as CELLSNET-41189) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.