Apply style to worksheet cells - 'Styles' is not a member of 'Aspose.Cells.Workbook' error in .NET

I have recently upgraded my Aspose.Cells and now find that my code is not working when it comes to styles. Previously I would create several styles on the workbook as follows:
Dim wb As Workbook = New Workbook()
Dim s As Integer = wb.Styles.Add
Dim DateColStyle As Aspose.Cells.Style = wb.Styles(s)
DateColStyle.HorizontalAlignment = TextAlignmentType.Left
DateColStyle.Number = 15
s = wb.Styles.Add
Dim CurrencyColStyle As Aspose.Cells.Style = wb.Styles(s)
CurrencyColStyle.HorizontalAlignment = TextAlignmentType.Right
CurrencyColStyle.Number = 4
Dim styleFlag As StyleFlag = New StyleFlag()
styleFlag.HorizontalAlignment = True
styleFlag.NumberFormat = True

Later on, I would apply these styles to cells as needed. How can I create the styles and then apply them later to cells please?


We obsoleted Workbook.Styles attribute some years ago, see the public API section. Here I will quote the announcement:

Property Workbook.Styles & Class StyleCollection Obsoleted

It is advised to use the Workbook.CreateStyle method to create and manipulate style for Workbook instance instead of creating a Style with StyleCollection.Add method. Moreover, Workbook.GetNamedStyle(string) method can be used to get named style instead of StyleCollection[string].

And, later on we removed the attribute from the APIs list. See the Release notes document for your reference. I will quote the relevant description here:

Deletes obsoleted Workbook.Styles property

Use Workbook.CreateStyle() to create and manipulate style for workbook instead of StyleCollection.Add(); Use Workbook.GetNamedStyle(string) to get named style instead of StyleCollection.

In short, please use Workbook.CreateStyle() to instantiate Style object.

Hope, this helps a bit.