调用 GetPreferredCellSize
- System.Drawing.Size sz;
- fpSpread1.ActiveSheet.SetValue(0, 0, "Expand the cell to fit the text.");
- sz = fpSpread1.ActiveSheet.GetPreferredCellSize(0,0);
- fpSpread1.ActiveSheet.Columns[0].Width = sz.Width;
- MessageBox.Show("The width of the cell is " + sz.Width.ToString());
复制代码 |