RadGridView with Print option

2 posts, 0 answers
  1. Praneeth
    Praneeth avatar
    2 posts
    Member since:
    Sep 2015

    Posted 20 Jul 2016 Link to this post

    In your radgrid view demo code:
    Im unable to find grid.ExportToWorkbook();
    this line is failing for me:
    Workbook currentWorkbook = grid.ExportToWorkbook();

    Code:-------------------------------------------------------------------------------------------------------
    private static Workbook CreateWorkbook(RadGridView grid, PrintSettings settings)
    {
    EventHandler<GridViewElementExportingToDocumentEventArgs> elementExporting = (s, e) =>
    {
    var documentVisualExportParameters = e.VisualParameters as GridViewDocumentVisualExportParameters;

    if (documentVisualExportParameters != null)
    {
    if (e.Element == ExportElement.HeaderRow)
    {
    if (settings.HeaderBackground != null)
    {
    documentVisualExportParameters.Style = new CellSelectionStyle() { Fill = new PatternFill(PatternType.Solid, settings.HeaderBackground, settings.HeaderBackground) };
    }
    }
    else if (e.Element == ExportElement.GroupHeaderRow)
    {
    if (settings.GroupHeaderBackground != null)
    {
    documentVisualExportParameters.Style = new CellSelectionStyle() { Fill = new PatternFill(PatternType.Solid, settings.GroupHeaderBackground, settings.GroupHeaderBackground) };
    }
    }
    else if (e.Element == ExportElement.Row)
    {
    if (settings.RowBackground != null)
    {
    documentVisualExportParameters.Style = new CellSelectionStyle() { Fill = new PatternFill(PatternType.Solid, settings.RowBackground, settings.RowBackground) };
    }
    }
    }
    };

    grid.ElementExportingToDocument += elementExporting;

    Workbook currentWorkbook = grid.ExportToWorkbook();

    return currentWorkbook;
    }
  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    393 posts

    Posted 22 Jul 2016 Link to this post

    Hi Praneeth,

    The ExportToWorkbook method was introduced in R1 2016. Can you please confirm what is the version of the controls that you are using? Please review the following article from our documentation - Modify RadGridView`s Content Before Exporting - where you can find the needed binaries that you have to reference as well.

    Regards,
    Stefan Nenchev
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top