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

4 posts, 0 answers
  1. Laxmi
    Laxmi avatar
    2 posts
    Member since:
    Apr 2015

    Posted 10 Jun 2015 Link to this post

    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>");
            }
        }
    }

  2. Stefan
    Admin
    Stefan avatar
    1073 posts

    Posted 11 Jun 2015 Link to this post

    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
  3. Laxmi
    Laxmi avatar
    2 posts
    Member since:
    Apr 2015

    Posted 11 Jun 2015 in reply to Stefan Link to this post

    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

     

  4. Stefan
    Admin
    Stefan avatar
    1073 posts

    Posted 12 Jun 2015 Link to this post

    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
Back to Top