Columns widths not maintained while copying worksheet in macOS

Hi we are trying to do the same thing. It seems like the Workbook.copy method works fine, but the Worksheet.copy method is messing with the column widths and making them all a little bit bigger. Nothing seems to work adding different copy options, even setting the default font. We are using Cells for .NET v19.8.0.

Here is a sample of the basic test we are doing:

        Workbook wb = new Workbook("./TestWorkbook.xlsx");
        Workbook outputWb = new Workbook();

        // This does change the widths.

        // This does not change the widths.
        // outputWb.Copy(wb);




Please try using our latest version/fix: Aspose.Cells for .NET v19.11.
If you still find the issue with v19.11, kindly do provide your template file “TestWorkbook.xlsx”, we will check it soon.

PS. Please zip the file prior attaching.

Thanks for the quick response! Unfortunately looks like the issue still persists. Here is our test file. (6.7 KB)

Thanks for the help!

Thank you for providing sample file. I have tested the sample code with the template file but could not observe any issue in Windows. However when same issue is tested in macOS with .NET Core version, the issue is reproduced as stated by you. Similarly when we try copying workbook instead of worksheet, the issue is no more there.

You have mentioned that you are using .NET version whereas issue is being reproduced in .NET Core (Visual Studio 2019 for macOS). Please share your complete environment details like OS, .NET framework etc. for our reference. If possible share a simple runnable console application solution with us for our testing and reference.

Here are my basic details:
AspNetCore Version 2.2.6
Aspose Cells Versions 19.11.0
macOS Version 10.14.6

Let me know if you need any more information, thanks!

Here is a basic example.

Workbook wb = new Workbook("./TestWorkbook.xlsx");
Workbook outputWbBad = new Workbook();
Workbook outputWbGood = new Workbook();

// This does change the widths.

// This does not change the widths.


Thank you for providing more details. We were able to observe the issue 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-44 – Column widths not maintained while copying Worksheet

Please try this code:

outputWbBad.DefaultStyle = wb.DefaultStyle;

When you do WorkSheet Copy, if you want to get the same column width, you also need to set the font style.
So CopyTheme and set DefaultStyle will make sure all font and style copied to dest-worksheet.
If you copy the whole workbook, you do not need to do it.

Let us know your feedback.

Thank you very much! When I add CopyTheme it is now preserving the column widths.

Now I’m wondering if we are copying worksheets from multiple workbooks can we use copy theme every time before we do Worksheets[0].Copy? Will the widths revert back if we copy the old theme back after the worksheet has already been copied over?


Yes, you will copy theme from each workbook (for the sheet(s) to be copied) into your destination workbook.

No, it will not revert back the columns’ width.

Please try your scenario/ case and in case you find any issue, let us know with details, sample code and template files, we will check it soon.