This is a migrated thread and some comments may be shown as answers.

RadGridView with Print option

1 Answer 186 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Praneeth
Top achievements
Rank 1
Praneeth asked on 21 Jul 2016, 04:34 AM
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;
}

1 Answer, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 22 Jul 2016, 12:44 PM
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.
Tags
GridView
Asked by
Praneeth
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Share this question
or