Keep column width when exporting to Excel from C1FexGrid using C1Excel

Posted by: luis_carlosh on 15 February 2022, 8:22 am EST

  • Posted 15 February 2022, 8:22 am EST


    I am exporting to an Excel file from C1FlexGrid via C1Excel . The columns in C1Flexgrid are set to AutoSize=true, but when exporting to Excel using C1Excel, it does not maintain the width of the columns. How do I match the width of the columns of C1FlexGrid in C1Excel so that the final result exported in Excel shows the same width of columns?
  • Replied 15 February 2022, 8:06 pm EST

    Hi,

    We recommend you use the SaveExcel Extension method of C1FlexGrid that you use by adding a reference to the C1.Win.C1FlexGrid.ImportExport library. It will export the FlexGrid column with their widths.

    If you are manually creating an excel file using the C1Excel then you will need to set the Width property of the XLColumns according to the WidthDisplay property of the column of FlexGrid.

    If you want to autosize the columns in the XLBook then you can refer to the product sample AutoSizeColumns installed at the location \Documents\ComponentOne Samples\WinForms\v4.5.2\Excel\CS in your system, which uses a method to manually resize all the columns in the Excel sheet to fit the longest field.

    Regards
    Avnish
Need extra support?

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

Learn More

Forum Channels