Themes don't appear to be copied by Copy method on Aspose.Cells.Worksheet

The Copy(sourceSheet) Method of the Aspose.Cells.Worksheet class does not appear to copy the Themes/Theme colors from the source Workbook that contains sourceSheet to the intended Destination Worksheet.

Manually copying the source Workbook Theme's colors from the source Workbook to the Destination Workbook via code like this below does not change the colors in the Destination Workbook and Worksheets. Can you let me know if this is an issue or have I missed something.

Color[] colors = new Color[12];
colors[0] = sourceWorkbook.GetThemeColor(ThemeColorType.Background1);
colors[1] = sourceWorkbook.GetThemeColor(ThemeColorType.Text1);
colors[2] = sourceWorkbook.GetThemeColor(ThemeColorType.Background2);
colors[3] = sourceWorkbook.GetThemeColor(ThemeColorType.Text2);
colors[4] = sourceWorkbook.GetThemeColor(ThemeColorType.Accent1);
colors[5] = sourceWorkbook.GetThemeColor(ThemeColorType.Accent2);
colors[6] = sourceWorkbook.GetThemeColor(ThemeColorType.Accent3);
colors[7] = sourceWorkbook.GetThemeColor(ThemeColorType.Accent4);
colors[8] = sourceWorkbook.GetThemeColor(ThemeColorType.Accent5);
colors[9] = sourceWorkbook.GetThemeColor(ThemeColorType.Accent6);
colors[10] = sourceWorkbook.GetThemeColor(ThemeColorType.Hyperlink);
colors[11] = sourceWorkbook.GetThemeColor(ThemeColorType.FollowedHyperlink);

destinationWorkbook.CustomTheme(sourceWorkbook.Theme, colors);

for (int i = 0; i < 56; i++)
{
destinationWorkbook.ChangePalette(sourceWorkbook.Colors[i], i);
}

Many Thanks

Hi,


We are sorry for your issue.

Could you attach your template Excel file and also output file here, we will check your issue soon.

Thank you.

Hi Travom,


I was wondering if you found out what went wrong with your attempt to copy theme colors from a source file to a destination file? We are actually trying to do the same thing although slightly differently, but the result is the same; The destination file doesn’t have the source file’s settings.

Note: we are calling “Workbook.CustomTheme()” method only.

Hi Sandie-Roy,


We appreciate if you could paste your sample code or attach a sample console application (you may zip prior attaching here) with your template files here, we will check your issue soon. If we found the issue, we will log it into our database, so your issue could be fixed soon.

Thank you.

Hi,


I have attached a small project that opens two excel files, then attempts to copy the theme from the first excel file “test theme source.xlsx” into the second file “test theme destination.xlsx”. So you can see the original copy of the “test theme destination.xlsx” after the test run, running the poject actually generated a new file called “generated file.xlsx” in the same folder as the “test theme destination.xlsx”.

Please run the attached project. This will display a window with two text boxes paired with buttons “…”, and a large button “Copy Theme” that will execute the theme copying code. To select the source file, click the “…” button next to its text box and select the attached file “test theme source.xlsx”. Similarly, you can select the destination file using the button next to its TextBox. When you have both file locations visible in the textboxes, click the button called “Copy Theme”.

The result of the steps above will be that an excel file called “generated file.xlsx” is generated in the same folder as the destination file “test theme destination.xlsx”. The generated file actually copies the source files color scheme when you look at the generated file closely, but the theme is not actually selected in the themes list.

Hi Sandie-Roy,

I have not got access to your attached files...not sure if this is intended, but if you can or would like to re-send and give me access I'd be happy to look at them in light of the issues I have raised, and if I can throw some light on the problem then would be happy to.

Cheers,

Mike

Hi,


Sorry, not sure why you couldn’t access it but I have just attached another re-zipped copy of the project.

It’s probably a forum setup. Make sense that only Aspose staff could access given files.

Hi,

Not sure either, but shows "Attachment: Present (inaccessible)" in the header to your post...???

Maybe you have made it private...???

Can see that it is called MultipleWorkbookTest.zip...???

Cheers,

Mike

Hi Travom,

Sorry, I can't find any setting that will release my attached files to you. To put your mind at ease the project I have attached is basically the same as your code, except I don't have the following block.

for(int i = 0; i < 56; i++)

{

destinationWorkbook.ChangePalette(sourceWorkbook.Colors[i],i);
}

The excel files are as follows:

"test theme source.xlsx" - themed with "Aspect" theme.

"test theme destination.xlsx" - themed with "Waveform" theme, and with a table (unmodified; columns names as default i.e. "Column1")

Hi Sandie-Roy,


Thanks for the template files and sharing the sample project

I can notice the issue as you have mentioned. The theme is not copied properly from the source workbook to destination workbook as you have pointed out. I tested by using the sample project attached by you with your template file.

I have logged a ticket with an id “CELLSNET-41646” for your issue. We will look into your issue to figure it out soon.

Thank you.


Hi,

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

We have added Workbook.CopyTheme method in the new Aspose.Cells for .NET v7.4.3.2.

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

Thanks Shakeel,

I tried out the Workbook.CopyTheme method in 7.4.3.2 and it seems to resolve the issues I had with Themes and Fonts.

Many Thanks,

Mike

Hi,


Good to know that the new fix/version: v7.4.3.2 meets your needs.

Feel free to contact us any time if you have further queries or have any other issue, we will be happy to assist you soon.

Thank you.

Hi!


Can you please tell me what the workbook.CopyTheme method does? I have to copy the chart settings, cell formatting , font ,colors etc from an existing workbook(like a template) to a new one and change only the data in the new one.

Thanks.

Hi,


Well, I am afraid, Workbook.CopyTheme would not suit your needs as it only copies Font attribute(s) from the source to the destination workbook, it will not copy cells formatting and chart objects. The best way to cope with it is you have to use Range.CopyStyle() or Range.Copy() method. Please see detailed document with sample code example to demonstrates the usage here.

Thank you.