Issue with exporting to Excel

Posted by: wp_pietf on 8 September 2017, 3:21 pm EST

  • Posted 8 September 2017, 3:21 pm EST


    in the old days when we export an fpSpread to Excel with the ExcelSaveFlags.SaveCustomColumnHeaders all of the column headers were properly aligned (horizontally and vertically as well)
    Now whith v9 the headers seems to inherit the aligning of the column itself. This is not the behaviour I want.

    How can I get back the old behaviour.

    Thanks in advance

  • Replied 8 September 2017, 3:21 pm EST


    Are you using code similar to this?

    fpSpread1.ActiveSheet.ColumnHeader.Cells[0, 0].Text = "Brakes";
    fpSpread1.ActiveSheet.Rows.Count = 5;
    fpSpread1.ActiveSheet.ColumnHeader.Columns[0].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
    fpSpread1.ActiveSheet.ColumnHeader.Columns[0].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Right;

    fpSpread1.SaveExcel("c:\\test.xls", FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders);

    Thanks, Gina
  • Replied 8 September 2017, 3:21 pm EST

    Hi Gina,

    thanks for your reply.
    I found out I did not specify vertical and horizontal alignment in the headers at all.
    Is this necessary in V9 because in V2.5 it seems to be the default behaviour as far as I can see.


  • Marked as Answer

    Replied 8 September 2017, 3:21 pm EST


    The default setting for the horizontal alignment is center and vertical is not set. If you want different settings then you should set the alignment (can also set defaultstyle for the column header). A lot of features have been added since 2.5 for styles so that is probably why the behavior is different from 2.5.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels