回复 1楼zhengqy810624的帖子
zhengqy810624 你好
针对你的问题,你可以调用以下方法来计算Span之后的行高,代码如下:
- private float GetRowBestHeight(int viRow)
- {
- Graphics vgphGraphics = fpSpread1.CreateGraphics();
- int iLoop = 0;
- float fBestHeight = 0;
- SizeF sfBestSize = default(SizeF);
- float fWidth = 0;
- while ((iLoop < fpSpread1.ActiveSheet.ColumnCount - 1))
- {
- fWidth = 0;
- for (int iTemp = 0; iTemp <= (fpSpread1.ActiveSheet.Cells[viRow, iLoop].ColumnSpan - 1); iTemp++)
- {
- fWidth += fpSpread1.ActiveSheet.Columns[iLoop + iTemp].Width;
- }
- sfBestSize = vgphGraphics.MeasureString(fpSpread1.ActiveSheet.Cells[viRow, iLoop].Text, fpSpread1.Font, Convert.ToInt32(fWidth));
- if (sfBestSize.Height > fBestHeight)
- {
- fBestHeight = sfBestSize.Height;
- }
- iLoop += fpSpread1.ActiveSheet.Cells[viRow, iLoop].ColumnSpan;
- }
- return fBestHeight;
- }
复制代码 |