lud 你好,感谢把问题反馈给我们,确实有该问题出现,现在需要自定义方法去计算 Row 高,请尝试下面代码:
- private void Form1_Load(object sender, EventArgs e)
- {
- FarPoint.Win.Spread.CellType.TextCellType textCellType=new FarPoint.Win.Spread.CellType.TextCellType();
- textCellType.WordWrap = true;
- this.fpSpread1.ActiveSheet.Columns[0].CellType = textCellType;
- this.fpSpread1_Sheet1.AddSpanCell(0, 0, 2, 2);
- this.fpSpread1_Sheet1.Cells[0, 0].Text = "tetesttestessttestessttestessttestessttestesttestest";
- this.fpSpread1_Sheet1.Rows[0].Height = GetRowBestHeight(0,System.Drawing.Graphics.FromHwnd(new IntPtr()));
- }
- private float GetRowBestHeight(int viRow, System.Drawing.Graphics vgphGraphics)
- {
- int i = 0;
- float bestHeight = 0;
- SizeF bestSize = default(SizeF);
- float width = 0;
- while ((i < this.fpSpread1_Sheet1.ColumnCount - 1))
- {
- // Calculate width of cell based on column span
- width = 0;
- for (int iTemp = 0; iTemp <= (this.fpSpread1_Sheet1.Cells[viRow, i].ColumnSpan - 1); iTemp++)
- {
- width += this.fpSpread1_Sheet1.Columns[i + iTemp].Width;
- }
- bestSize = vgphGraphics.MeasureString(this.fpSpread1_Sheet1.Cells[viRow, i].Text,new Font("Microsoft Sans Serif",(float)(8.25)), Convert.ToInt32(width));
- if (bestSize.Height > bestHeight)
- {
- bestHeight = bestSize.Height;
- }
- i += this.fpSpread1_Sheet1.Cells[viRow, i].ColumnSpan;
- }
- return bestHeight;
- }
复制代码 |