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

Customize grid data for biff excel export

1 Answer 28 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Prathibarani asked on 12 Sep 2013, 07:57 PM
The result set from database comes back as the following data. It is parent child relation. TransactionID 1009 has 3 child records in the database with 3 accounts. The total transaction amount is $12/- (3 + 4+5).
So parent table has ID and other data. Child table has Account#, AccountName, Amount, parentID and some other fields.
ID  Name    Account#    AccountName Amount
1007    Sam 31747   a   1
1008    Sam 31748   av  2
1009    Sam 31797   ab  3
1009    Sam 31798   ac  4
1009    Sam 31799   ad  5
When it is displayed in the radgrid, we are showing it like this:
ID  Name    AccountNum  AccountName Amount
1007    Sam 31747            a        1
1008    Sam 31748            av       2
1009    Sam 31797            Ab ($3)  12
            31798            Ac ($4)
            31799            Ad ($5) 
We are achieving this by doing this logic:
While (reader.Read())
     //logic to check old transaction or new transaction by comparing ID
         If (newID != oldID)
                //new transaction. So do the code
        //still previous transaction. So concatenate account numbers
        accountNum += "<br/>" + reader.GetString(reader.GetOrdinal("AccountNumber"));
             accountName += "<br/>" + reader.GetString(reader.GetOrdinal("AccountName"));
             amount += reader.GetDecimal(reader.GetOrdinal("Amount"));
I want this grid data to be exported to BIFF format excel like this:
ID  Name    Account#    AccountName Amount
1007    Sam                            1
            31747         a   
1008    Sam                            2
             31748        av  
1009    Sam                            12
             31797        Ab ($3)     
             31798        Ac ($4) 
             31799        Ad ($5) 
I tried using ExportInfrastructure and shiftingRowsDown method in a loop, it works for only 1007 and 1008 rows. But not to 1009. I understand why. That has been treated as 1 row eventhough there are multiple accounts. The account# column is just string concatenation. So, when I am exporting looks like I need to use my original dataset. 
I tried to create another radgrid programmatically and assign original result set. We have a btn upon clicking it, I export data to excel like this:
protected void btnExport_Click(object sender, EventArgs e)
protected void rgdChecks_BiffExporting(object sender, Telerik.Web.UI.GridBiffExportingEventArgs e)
Where should I programmatically create radgrid and do customize data to look like above.
We do not want to use hierarchical grid.
Please let me know how to get this kind of output?

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 17 Sep 2013, 10:45 AM
Hi Prathibarani,

I demonstrates how this could be achieved by using a Biff export. Basically you remove the text from the column in order to looks like a one item. I attached the sample to this tread.

If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question