Free Support Forum - aspose.com

Autofit cells after a cell is edited

I am using Asp.net 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?

Hi,


1) If you are using Aspose.Cells library, see the document on how to auto-fit rows/cols and wrapping text in the cells:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/autofit-rows-columns.html
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/configuring-alignment-settings.html

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

GridWeb1.WebWorksheets[0].AutoFitRows();


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

WebWorksheets sheets = GridWeb1.WebWorksheets;
sheets.Clear();
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;
cell.SetStyle(style);
//…


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.

Hi,

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

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