← 返回所有博客文章

下面的代码可以让第一列自动调整宽度以适应该列中拥有最宽的文本单元格:

[Visual Basic .NET Code]

Dim s As Single 
s = FpSpread1.ActiveSheet.GetPreferredColumnWidth(0) 
FpSpread1.ActiveSheet.Columns(0).Width = s + 1


[C# Code]

float s;
s = FpSpread1.ActiveSheet.GetPreferredColumnWidth(0);
FpSpread1.ActiveSheet.Columns(0).Width = s + 1;