Free Support Forum -

Set column width having merged cells in the worksheet in .NET

I am having a problem setting som colum width to zero in the attached spreadsheet. I am trying to set colums R though Z to zero using the followinf code:

Dim i, j As Integer

For i = 0 To wb.Worksheets.Count - 1
For j = 1 To 30
wb.Worksheets(i).Cells.SetColumnWidth(j, 0)

What it seems to do is starting the column index after the merged columns That just doesnt seem right.



I tested your code with your template file with latest version/fix v6.0.0.6(attached), it works fine. I think it works same as MS Excel.

Please try it and let us know if it works fine.

Thank you.

Thanks. I tried that version and I get a ton of Error 4 'Style' is not a member of 'Aspose.Cells.Cell' errors.

I'm currently using version 4.8. Is there a version I can upgreade to that my issue will be resolved without having to redo all the Style applications?

Thanks agian.


Hi Chris,

Well, you may try some other versions (if possible for you and your license allows) e.g v4.9 etc.

And regarding using latest versions with their APIs, for
your complete reference, I think firstly you should check the release notes for
different official versions of Aspose.Cells for .NET (especially v5.0.0 and
5.1.0 etc.).<o:p></o:p>

Note: Check the description under "Notable Changes for Existing Users" for API changes.

For Workbook.Open and Workbook.Save methods warning messages, please see the documents for your reference:

Moreover, please check the documentation of the product for complete details:

Let me come towards your significant errors that you may encounter, so you can fix them accordingly:

1) You need to import the relevant namesapaces to your demo pages or use fully qualified naming when declaring objects for classes etc.:


using System;

using System.Web;

using Aspose.Cells;

using Aspose.Cells.Pivot;


2) As I said above, some classes are renamed. e.g

i) Validations --> ValidationCollection

ii) PivotTable --> PivotTableCollection


3) Aspose.Cells.Style property is eliminated/obsoleted now, you should adjust your code to use Aspose.Cells.GetStyle() and Aspose.Cells.SetStyle() methods, it will also enhance the performance to certain extent:


Your sample code using Style attribute should be updated accordingly, e.g

Style style = wsNdaa.Cells[0, 0].GetStyle();

style.Font.IsBold = true;

wsNdaa.Cells[0, 0].SetStyle(style);

Styyle style2 = cells["I1"].GetStyle();

style2.HorizontalAlignment = TextAlignmentType.Center;

style2.BackgroundColor = System.Drawing.Color.Navy;

style2.Font.IsBold = true;


For complete reference about Cell.GetStyle/SetStyle approach, please see the documents in the section:

4) Please check Aspose.Cells for .NET API Reference: