michael 你好,
1.可以通过 TextCellType 单元格类型实现列头单元格的换行:
- this.FpSpread1.ActiveSheetView.ColumnHeader.RowCount = 2;
- FarPoint.Web.Spread.TextCellType textType = new FarPoint.Web.Spread.TextCellType();
- textType.Multiline = true;
- this.FpSpread1.ActiveSheetView.Cells[0, 0].CellType = textType;
- this.FpSpread1.ActiveSheetView.Cells[0, 0].Text = "第一行\n第二行";
- this.FpSpread1.ActiveSheetView.ColumnHeader.Cells[0, 0].CellType = textType;
- this.FpSpread1.ActiveSheetView.ColumnHeader.Cells[0, 0].Text = "第一行\n第二行";
复制代码 效果图:
png
2.关于使所有列都自动适应宽度的,可以通过循环来实现,例如表单中共有 10 列:- for (int i = 0; i < 10; i++)
- {
- FpSpread1.SizeToFit(i);
- }
复制代码 |