I am trying to set horizontal alignment of cells when exporting data to excel. Cells with numbers should align right.
What I did:
First creating the table:
var table = CurrentWorksheet.Range(1, 1, customDataTable.Rows.Count + 1, customDataTable.Headers.Count).CreateTable();
table.Theme = XLTableTheme.TableStyleMedium15;
then I tried two variants for setting the alignment:
CurrentWorksheet.Cell(rowIndex, colIndex).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Right);
and
CurrentWorksheet.Cell(rowIndex, colIndex).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
Both should work according to the documentation, but it does not for me! Am I doing something wrong?