Free Support Forum - aspose.com

Setting the width for columns in excel

Hello,

I am fetching data from the DB and binding to excel. The style for cells is being set by code. However when the excel opens up with the data, the columns are in shrunked state. I am unable to set the width of the column based on the length of the text in the cell. Well i tried using the style.ShrinktoFit property, but if i use this i get an error that says the aspx page is alread yopen and cannot open another. But the thing is i am opening the excel in the same browser, there is no question of a new page being opened... can anyone please help? Here is my code to set style -

private void SetreportStyles(Workbook workbook)

{

int styleIndex = workbook.Styles.Add();

Aspose.Cells.Style style = workbook.Styles[styleIndex];

style.Font.IsBold = true;

style.HorizontalAlignment = TextAlignmentType.Left;

style.TextDirection = TextDirectionType.Context;

style.ShrinkToFit = true;

style.Name = "Custom Style";

}

Please restart your IIS and vs.net.

I make a simple test case with latest version of Aspose.Cells and it works fine. Please check the attached files.

Thanks, for the help

Rgds Soumya