Free Support Forum -

Autofit cells after a cell is edited

I am using aspose.cells.

How would I autofit or autoformat cells after they have been edited by the user?

Also, is there an option to make the whole grid or worksheet textwrap?


1) If you are using Aspose.Cells library, see the document on how to auto-fit rows/cols and wrapping text in the cells:

2) If you are using GridWeb, you may use the following methods e.g
AutoFitRow, AutoFitColumn, AutoFitRows, AutoFitColumns of the WebWorksheet class.


To wrap text, you may use TableItemStyle object and specify wrapping text attributes accordingly for your desired cells, e.g

WebWorksheets sheets = GridWeb1.WebWorksheets;
WebWorksheet sheet = sheets[sheets.Add(“demo1”)];
WebCell cell = sheet.Cells[0,0];
cell.StringValue = "Demo Text. This is the long text format and… ";

Aspose.Cells.GridWeb.TableItemStyle style = cell.GetStyle();

style.Wrap = true;

Thank you.

I am using gridweb.

I am aware of the autofit, but is there no event for when a user edits a cell so that I can auto fit it when the event is called?

I am also aware of making each individual cell textwrap… I would like to make the whole grid text wrap. My grid is sized dynamically based on databound data.


I think, for your requirement, you should handle CellDoubleClick event.

Please see this document for your complete reference:
Working with Aspose.Cells.GridWeb Events