We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Column Width // cell formatting :: Need resolution A.S.A.P


I am facing a cell formatting related issue when trying to insert new columns in a spreadsheet.

When I specify a certain width to a column say “C” and put a value such as ‘c99’ in it, and try to insert 10 columns in either column A or B, the new transposed column “C” (which now should be “M”) does not have the same formatting as it’s original “C”.

Right now, this is specific to the column width. I haven’t checked the rest of the properties out.

Please find 2 spreadsheets attached (one blank and the other with some some sample formatting) this email message. I have tried this on both and they fail.

More, please find the code I used to replicate and test this issue at the end of this message.

Appreciate any help to resolve this issue.


// Code block
// ---------------------------------------------------------------------
// Assume that the variable ‘workbook’ has been instantiated and associated with one/either of the excel files attached.

var grid = workbook.Worksheets[0];

Cell c = grid.Cells.FindString(“c99”, null);

double originalWidth = grid.Cells.GetColumnWidth(c.Column);

grid.Cells.InsertColumns(1, 32);

// u can try to comment out the following line and try as well. the result is the same in both cases.
// However, must note here that the column number is automatically changed when I insert the columns in the previous statement.
c = grid.Cells.FindString(“c99”, null);

Assert.AreEqual(originalWidth, grid.Cells.GetColumnWidth(c.Column));
// ---------------------------------------------------------------------


Thanks for pointing it out.

Yes, we noticed the issue with Cells.InsertColumns() method. Actually Cells.InsertColumns is more optimized regarding memory consumption and fast, it takes the default column width (8.43…) to insert new columns. We will check if we can enhance it more. I think, for the time being, you may use Cells.InsertColumn() method instead (if it fits your need).


you may change your code i.e.,

grid.Cells.InsertColumns(1, 32);


for (int i = 1; i <= 32; i++)

Thank you.

Hi Amjad,

Thank you for your prompt reply.

I just tested what you mentioned and it works.
We will go ahead and use this for the time being.

However, it will be great to have a fix for this as you already mentioned that InsertColumns is more optimized, for the future.

Thanks again.


Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Please try the attached latest version of Aspose.Cells. We have fixed your mentioned issue regarding Cells.InsertColumns.

Thank You & Best Regards,


Thank you for getting back to me with the update/resolution.
I have tested and applied it and it works fine.