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

How to write additional data to the stream using ExportToXlsx on RadGridView

3 Answers 109 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Laxmi
Top achievements
Rank 1
Laxmi asked on 11 Jun 2015, 12:44 AM

Hi,

 

We are using ExportToXlxs to export data from RadGridView in our application. Wondering, how to write additional data to the stream like below using the ElementExportingToDocument event. Thanks!

  

private void RadGridView1_ElementExported(object sender, GridViewElementExportedEventArgs e)
{
    if (e.Element == ExportElement.Row)
    {
        Employees obj = e.Context as Employees;
        if (obj != null)
        {
            e.Writer.Write(String.Format(@"<tr><td style=""background-color:#CCC;"" colspan=""{0}"">",
                ((IEnumerable<Telerik.Windows.Controls.GridViewColumn>)RadGridView1.Columns).Count()));
            e.Writer.Write(String.Format(@"<b>Birth date:</b> {0} <br />", obj.BirthDate));
            e.Writer.Write(String.Format(@"<b>Hire date:</b> {0} <br />", obj.HireDate));
            e.Writer.Write(String.Format(@"<b>Address:</b> {0} <br />", obj.Address));
            e.Writer.Write(String.Format(@"<b>City:</b> {0} <br />", obj.City));
            e.Writer.Write(String.Format(@"<b>Notes:</b> {0} <br />", obj.Notes));
            e.Writer.Write("</td></tr>");
        }
    }
}

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 11 Jun 2015, 02:19 PM
Hello Laxmi,

For the time being, such customizations are  not supported by ElementExportingToDocument event. If you need to add additional data to the stream, you can use the Export method of RadGridView and subscribe to the ElementExported event as in the code you pasted. You can also take a look at our documentation on Export functionality of RadGridView for further reference.

Best Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Laxmi
Top achievements
Rank 1
answered on 11 Jun 2015, 04:27 PM

Thanks for the response, Stefan!

But, we have moved on from Export to ExportToXlsx, so that we can export the excel to the .xlsx format, which is not happening using the Export method on the RadGridView.

 So, is there a way by which we can achieve exporting to the .xlsx format and also able to write additional data to the stream which is very much required in our case?

 

Regards,

Laxmi

 

0
Stefan
Telerik team
answered on 12 Jun 2015, 02:45 PM
Hi Laxmi,

For this scenario I can suggest you using RadSpreadProcessing library. Please check the SpreadProcessing Integration online demo for further reference. Note, that it is for Silverlight, but the same approach applies for WPF as well, since RadGridView for Silverlight and RadGridView for WPF share a common code base and the same API.

Hope this helps.

Best Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Laxmi
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Laxmi
Top achievements
Rank 1
Share this question
or