Vertical Alignment Not Working

I am using the following code to set vertical alignment on a cell, but it is not working.

// Get worksheet cells collection
Cells cells = _workbook.Worksheets[sheetIdx].Cells;
// Get the specified cell
Cell cell = cells[row, col];

// Set the style
Style style = cell.GetStyle();
style.VerticalAlignment = TextAlignmentType.Center;
cell.SetStyle(style);

@FireWave

Thanks for using Aspose APIs.

We have tested the vertical alignment using the following code and it works fine. Please check the output Excel file generated by the code as well as screenshot for a reference.

Download Link:
Output Excel File.zip (5.6 KB)

C#

Workbook wb = new Workbook();

Worksheet ws = wb.Worksheets[0];

Cell cell = ws.Cells["D4"];
cell.PutValue("Sample Text");

ws.Cells.SetColumnWidth(cell.Column, 30);
ws.Cells.SetRowHeight(cell.Row, 60);

Style st = cell.GetStyle();
st.VerticalAlignment = TextAlignmentType.Center;
st.HorizontalAlignment = TextAlignmentType.Center;
cell.SetStyle(st);

wb.Save("output.xlsx");

Screenshot:

I have solved the problem. It appears that if you apply borders to the cell more than once, then for some reason, the vertical alignment does not get applied.

@FireWave

It is good to know that you were able to resolve this issue. If you find some bug, you can provide us runnable sample code instead of some code snippet. We will execute your code at our end and replicate the issue and help you asap.