FlexGrid: Export to excel with ownerdrawn items?

Posted by: hdle on 28 November 2024, 1:08 pm EST

    • Post Options:
    • Link

    Posted 28 November 2024, 1:08 pm EST - Updated 28 November 2024, 1:13 pm EST

    Hi,

    Is there a way to export the flexgrid to excel with owner drawn items?

    In the image above, the color bars below Processing, Down, Available columns are the series color for the FlexChart above (not shown). They are drawn as just color rectangle in the owner draw of the grid. I would live it to be available in the Excel export. Is there a way to do that? currently, it doesn’t show up in export to Excel.

    Thanks,

    Hai

  • Posted 29 November 2024, 4:36 am EST

    Hi,

    how would you render this in excel? Your sample should work with a border, so you could use the C1Excel library (https://www.nuget.org/packages/C1.Excel for .NET6, different name for .NET framework, which is part of the WinForms license) to open the excel file that you previously saved and add borders.

    E.g. like this:

    C1XLBook excelBook = new C1XLBook();
    excelBook.Load(fileName);
    XLSheet  sheet = excelBook.Sheets[0];
    
    XLCell cell = sheet.GetCell(row, col);
    XLStyle style = cell.Style.Clone();
    style.BorderColorBottom = Color.Red;
    style.BorderTop = XLLineStyle.Thick;
    cell.Style = style;
    
    excelBook.Save(fileName);

    Hope this helps

    Wolfgang

  • Posted 29 November 2024, 5:32 am EST

    Hello Hai,

    The owner-drawn elements are drawn over the control and Excel does not draw such borders. As Wolfgang mentioned, you will need to post-process the excel exported by FlexGrid using the C1XLBook (C1.Excel API) to add borders. We have attached a sample project for your reference.

    Attachment: FlexGridExcelBorders.zip

    P.S. Thank you for your input Wolfgang!

    Best Regards,

    Kartik

  • Posted 2 December 2024, 11:05 am EST

    Wolfgang, Kartik,

    The solution you provide seems perfect. Thanks,

    Hai

    P.S. Wolfgang, I’m glad you’re still around here helping user!

Need extra support?

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

Learn More

Forum Channels