Free Support Forum -

Applying style at cell Level

Hi All,

In older version of aspose , we will apply style at cell Level like this..

sheet.Cells[0, col].Style.HorizontalAlignment = TextAlignmentType.Center;

But i am using aspose version .. in this I am getting one built in function SetStyle().

Now my question is If I want to apply the style as I mentioned

how to do achieve this in single statement as above..

sheet.Cells[0,col].SetStyle(..... continue here..

Please provide the code for this..


Hi Jack,

Please go through the information given in the link below. This will make you understand why this Style Get/ Set methods have been introduced.

You can use following lines of code to Get/ Set cell style.

Code snippet:
Dim workbook As New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)
Dim cellName As String = "A1"
Dim s As Style = sheet.Cells(cellName).GetStyle()
s.HorizontalAlignment = TextAlignmentType.Center

For further reference: