Column Widths not copied correctly

Column Widths are not copied correctly when using Copy Method of Worksheet.



See attached Source Spreadsheet and code below to replicate.



Columns T and Z are 8.43 width in the source spreadsheet. In the generated sheet they are 8.71.



Workbook sourceWorkbook = new Workbook(@“C:\Column Widths Issue.xlsb”);

Worksheet sourceWorksheet = sourceWorkbook.Worksheets[0];

Workbook destinationWorkbook = new Workbook();

Worksheet destinationWorksheet = destinationWorkbook.Worksheets.Insert(0, SheetType.Worksheet);

destinationWorksheet.Copy(sourceWorksheet, new CopyOptions { ColumnCharacterWidth = false });

destinationWorkbook.Save(@“C:\Column Width Issues Results false.Xlsb”, SaveFormat.Xlsb);

destinationWorksheet.Copy(sourceWorksheet, new CopyOptions { ColumnCharacterWidth = true });

destinationWorkbook.Save(@“C:\Column Width Issues Results true.Xlsb”, SaveFormat.Xlsb);

Hi Michael,

Thanks for your posting and using Aspose.Cells.

We were able to observe this issue. After worksheet is copied, the column widths from column T-Z do not remain same. We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSNET-42433.

Hi,

Thanks for your posting and using Aspose.Cells.

We have fixed this issue.

Please download and try the latest fix: Aspose.Cells for .NET (Latest Version) and let us know your feedback.

Hi Shakeel,

Have downloaded 7.7.2.3.

I can’t compile against this version…something has gone amiss. However can compile with 7.7.2. is fine.

Maybe the wrong dll has been uploaded…???

Issues relate to:

Error 10 ‘Aspose.Cells.Drawing.ShapeCollection’ does not contain a definition for ‘Count’ and no extension method ‘Count’ accepting a first argument of type ‘Aspose.Cells.Drawing.ShapeCollection’ could be found (are you missing a using directive or an assembly reference?)

Error 4 Could not find an implementation of the query pattern for source type ‘Aspose.Cells.NameCollection’. ‘GroupBy’ not found. Consider explicitly specifying the type of the range variable ‘name’.

Error 8 Could not find an implementation of the query pattern for source type ‘Aspose.Cells.ReferredAreaCollection’. ‘Where’ not found. Consider explicitly specifying the type of the range variable ‘oReferredArea’.

Error 6 Delegate ‘System.Func<TSource,int,bool>’ does not take 1 arguments

// Get all named cells/ranges
var oNames = Worksheet.AsposeWorksheet.Workbook.Worksheets.Names;

        // Group duplicates
        var oNameGroups = from name in oNames
                          group name by name.Text.ToUpper();

        foreach (var oNameGroup in oNameGroups)
        {
            if (oNameGroup.Count() <= 1)
            {
                continue;
            }
            string sRefersTo = null;
            foreach (var oName in oNameGroup.Where(oName => oName.RefersTo != null))
            {
                if (sRefersTo == null)
                {
                    sRefersTo = oName.RefersTo;
                }
                else if (sRefersTo != oName.RefersTo)
                {
                    // Found a named range with the same name and referring to a different range. Different sheets must have had the same named ranges
                    // May cause issues
                }
            }
            if (sRefersTo == null)
            {
                continue;
            }
            foreach (var oName in oNameGroup.Where(oName => oName.RefersTo == null))
            {
                oName.RefersTo = sRefersTo;
            }
        }
    }

Hi,

Thanks for your posting and using Aspose.Cells.

Please let us know your .NET Framework version. Are you using .NET Client Profile Framework? Because, there is a separate dll compiled for Client Profile version.

In case of 7.7.2, which folder’s dll you are using? Because there are several folders as shown in this screenshot.

In the case of 7.7.2 using \net.3.5

Project that references Aspose.Cells.dll is built against .NET Framework 4.

Thanks Shakeel,

Hope it is an easy fix.

Cheers,

Mike

Hi Mike,

Thanks for your feedback and using Aspose.Cells.

I have forwarded your request and we will provide you net3.5 related Aspose.Cells.dll asap. Once, it is available for you, we will notify you on this thread.

Thanks Shakeel.

I have not received the dll yet. Could I get you to follow up for me please.

Thanks,

Mike

Hi,


We are scheduled to release our next official release of the product i.e., Aspose.Cells for .NET v8.0.0.0 before the end of this week. You will be notified here once it is released, so you could install the version and get the Dll of your desired framework compiled version accordingly.

Keep in touch.

Thank you.


Thanks Amjad.

Regards,

Mike

6 posts were split to a new topic: Columns widths not maintained while copying worksheet in macOS