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

Free Support Forum - aspose.com

Column and row word wrapping within the Grid

I am trying to figure out how I can set the word wrapping to true so that the cells will wrap and grow with the cell as needed. Right now, my cells cut off half of the text within it. I would also like to figure out how I can fix the headers to a fixed width that cannot be adjusted by the user.

Hi,

Please refer to the following code that defines how to wrap text for a cell for your need.

Sample code:

protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{

WebWorksheets sheets = GridWeb1.WebWorksheets;

// Clears all sheets.
sheets.Clear();

// Creates a new worksheet named "Invoice".
WebWorksheet sheet = sheets[sheets.Add("Invoice")];

sheet.Cells[0, 0].StringValue = "This is wraping text test";
// Sets the font size of the cell.
sheet.Cells[0, 0].Style.Font.Size = new FontUnit("10pt");
sheet.Cells[0, 0].Style.Font.Bold = true;
sheet.Cells[0, 0].Style.ForeColor = System.Drawing.Color.Blue;
sheet.Cells[0, 0].Style.BackColor = System.Drawing.Color.Aqua;
sheet.Cells[0, 0].Style.Wrap = true;

// Sets the column width.
sheet.Cells.SetColumnWidth(1, new Unit(80, UnitType.Point));
//set the row height
sheet.Cells.SetRowHeight(0, new Unit(40, UnitType.Point));


}

}

I would also like to figure out how I can fix the headers to a fixed width that cannot be adjusted by the user.

I think you may set GridWeb1.EnableClientResizeColumnRow property to false for your task.

Thank you.

Thank you very much, One more question?
Do you know if there is a way to set the row height to “Can Grow” if needed rather than setting it to a specific height when it needs to wrap the text.
Thanks,

Hi,

Well, you need to set/expand the height of a cell row to implement word wrap feature, this behavior is same with MS Excel as you may check.

Thank you.