Hello,
Spread is a great product, but does have a few gotchas. One of them is getting Column.Width set properly. You would think that the default would be no WordWrap but that is not the case. To work around this issue, I create a SetupSheetView method in every application with code in it like below:
Private Sub SetupFarPointSheetView(ByVal sheet As SheetView)
Try
With sheet
.SelectionUnit = Model.SelectionUnit.Cell
.DataAutoSizeColumns = False
' Set row headers to no wrap.
Dim rowRendererNoWrapText As New CellType.RowHeaderRenderer
rowRendererNoWrapText.WordWrap = False
.RowHeader.DefaultStyle.Renderer = rowRendererNoWrapText
' Set column headers to no wrap.
Dim columnRendererNoWrapText As New CellType.ColumnHeaderRenderer
columnRendererNoWrapText.WordWrap = False
.ColumnHeader.DefaultStyle.Renderer = columnRendererNoWrapText
End With
Catch ex As Exception
Throw
End Try
End Sub 'SetupFarPointSheetView
Once you have done the above, then you can use the SheetView GetPreferredColumnWidth method which has some overloads pertaining to column headers, spans, etc to get your column widths to behave the way you would expect them to from reading about GetPreferredWidth in the docs.
With Me.FpSpread1.ActiveSheet
For Each column As Column In .Columns
column.Width = .GetPreferredColumnWidth(column.Index, IgnoreHeaders:=False)
Next
End With