Copying worksheet with modified chart is changing the charts format


#1

I have a worksheet with a chart whhere specific components of the chart have been modified such as colors and text format of labels.

When I run the following code, the copied sheet shows slightly different colors and some of the text label formats are lost.

    static void Main(string[] args)
    {
        Workbook source = new Workbook(args[0]);
        Workbook target = new Workbook(args[1]);

        foreach (Worksheet ws in source.Worksheets)
        {
            Worksheet newWs = target.Worksheets.Add("myNewSheet_" + ws.Name);
            newWs.Copy(ws);
        }

        target.Save(target.AbsolutePath + "Copy_" + target.FileName);
    }

#2

@mhopkins,

Thanks for the code segment and details.

Could you provide your template files (input file(s) and output file(s)), we will check it soon.


#3

@Amjad_Sahi I have attached the workbook prior to running the above code as well as the output workbook which is missing the formatting. I have also attached an image which highlights the formatting differences.

Please could you take a look as soon as possible.

BeforeVsAfter.png (33.6 KB)
AsposeChartFormattingIssue.zip (35.2 KB)


#4

@mhopkins,
I have checked the sample code using latest version but could not observe the change in chart. Please try our latest version/fix: Aspose.Cells for .NET v19.7.4 (attached) and share your feedback.

Aspose.Cells19.7.4.zip (9.8 MB)


#5

@ahsaniqbalsidiqui I am now getting a corrupt workbook error when trying to initialize an Aspose Cells workbook using the 19.7.4 libraries.

I have attached my entire sample solution for you to see the behavior.AsposeMergeIssue.zip (5.0 MB)


#6

@mhopkins,

Thanks for the sample project.

The fix shared by Ahsan Iqbal has Aspose.Cells libraries for .NET 2.0 and .NET 4.0 framework versions. Since you are using .NET Core project, so the fix (common .NET 2.0 and 4.0 libraries) would not work there and you are getting the error. We will check if we could provide you .NET Standard fix. Alternatively, you may try to use .NET Standard version of the official release, i.e., Aspose.Cells for .NET v19.7 (you may get it from Downloads section or Nuget repos.) if it works and fixes the issue.


#7

Thanks for responding so quickly. I also tried the 19.7.0 package on Nuget and I am still seeing the error there.


#8

@mhopkins,
I have tried this scenario using Aspose.Cells for .NETStandard 2.0 but could not observe issue here as well. I have Excel 365 in my environment. Could you please share your environment details with us?
DotNetResult.PNG (30.5 KB)


#9

@mhopkins,
Here is a sample project for your reference which works fine. You may test it and provide your feedback.
AsposeCellsTest.zip (60.2 KB)


#10

@ahsaniqbalsidiqui looks like this is slightly better. However, the dot at the end of the green line is missing in the screenshot that you sent. The orange triangle formats are now appearing which is good.


#11

@mhopkins,
We were able to observe the issue where dot is missed while copying the worksheet but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNETCORE-29 – Chart modified slightly when worksheet is copied

#12

@mhopkins,
This is to inform you that we have fixed your issue (logged earlier as “CELLSNETCORE-29”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.


#13

Thanks for the update


#14

@mhopkins,
You are welcome.