# Query on making excel sheet of a report?

**URL:** <https://www.dynamicsuser.net/t/query-on-making-excel-sheet-of-a-report/48350>\
**Category:** Developers Forum\
**Created:** [September 24, 2013, 9:52am UTC](https://www.dynamicsuser.net/t/query-on-making-excel-sheet-of-a-report/48350 "2013-09-24T09:52:58Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Priya\_Singh](https://avatars.discourse-cdn.com/v4/letter/p/c57346/32.png) [@Priya\_Singh](https://www.dynamicsuser.net/u/Priya_Singh)\
**Post date:** [September 24, 2013, 9:52am UTC](https://www.dynamicsuser.net/t/query-on-making-excel-sheet-of-a-report/48350/1 "2013-09-24T09:52:58Z")

</div>

Hi All,

I amde a excel sheet of a report with the help of excel buffer table,but there is one problem come i.e the heading field comes after every single record,as follows

Vendor Name Purchase Balance

Vineet 1000000 50000

Vendor Name Purchase Balance

Rajiv 500000 70000

- 
- 
- 

Please help me about what i have to change so that heading part comes once and all records come after that.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![admin1](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/admin1/32/7476_2.png) [@admin1](https://www.dynamicsuser.net/u/admin1)\
**Post date:** [September 24, 2013, 9:58am UTC](https://www.dynamicsuser.net/t/query-on-making-excel-sheet-of-a-report/48350/2 "2013-09-24T09:58:41Z")

</div>

Well since we didn’t know how you created your report, then it’s difficult to say what you did wrong! [:)] And these Excel Buffer reports sometimes can be quite complex.

But you have to make sure that the header is only created once. If you report inserts the vendors on a normal dataitem in the OnAfterGetRecord trigger, then eventually create a variable to check if the Header has already been created, so that it should not do it again.

---

<div class="post-metadata">

**Author:** ![thomasbrodkorb](https://avatars.discourse-cdn.com/v4/letter/t/2acd7d/32.png) [@thomasbrodkorb](https://www.dynamicsuser.net/u/thomasbrodkorb)\
**Post date:** [September 24, 2013, 9:59am UTC](https://www.dynamicsuser.net/t/query-on-making-excel-sheet-of-a-report/48350/3 "2013-09-24T09:59:16Z")

</div>

When you are running this in a Report, you should write the Header cells in the OnPreDataItem and the lines in the OnAfterRecord Trigger.

This result Looks like you are writing everything in the OnAfterGetRecord.

Alternatively you can set a variable when you have created the Header cells and check if that variable already has a value before writing the Header cells.

---

<div class="post-metadata">

**Author:** ![mohana\_cse06](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@mohana\_cse06](https://www.dynamicsuser.net/u/mohana_cse06)\
**Post date:** [September 24, 2013, 9:59am UTC](https://www.dynamicsuser.net/t/query-on-making-excel-sheet-of-a-report/48350/4 "2013-09-24T09:59:28Z")

</div>

Can you show us the code in Vendor onAfterget record trigger?

you must have added header names code in Onaftergetrecord trigger…thats why each time header is also exported.

---

<div class="post-metadata">

**Author:** ![Priya\_Singh](https://avatars.discourse-cdn.com/v4/letter/p/c57346/32.png) [@Priya\_Singh](https://www.dynamicsuser.net/u/Priya_Singh)\
**Post date:** [September 24, 2013, 10:19am UTC](https://www.dynamicsuser.net/t/query-on-making-excel-sheet-of-a-report/48350/5 "2013-09-24T10:19:17Z")

</div>

i did’t write anything in onaftergetrecord.i made a function makeexceldatabody and i call this function in vendor onpresection and the code i write in MAKEEXCELDATABODY is

ExcelBuf.NewRow;

ExcelBuf.AddColumn(‘VendorName’,FALSE,’’,TRUE,FALSE,FALSE,’’);

ExcelBuf.AddColumn(‘Purchase’,FALSE,’’,FALSE,FALSE,FALSE,’’);

ExcelBuf.AddColumn(‘Balance’,FALSE,’’,FALSE,FALSE,FALSE,’’);

ExcelBuf.NewRow;

ExcelBuf.AddColumn(Vendor.Name,FALSE,’’,FALSE,FALSE,FALSE,’’);

ExcelBuf.AddColumn(Vendor.“Purchases (LCY)”,FALSE,’’,FALSE,FALSE,FALSE,’’);

ExcelBuf.AddColumn(Vendor.“Balance (LCY)”,FALSE,’’,FALSE,FALSE,FALSE,’’);

Thanks

---

<div class="post-metadata">

**Author:** ![admin1](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/admin1/32/7476_2.png) [@admin1](https://www.dynamicsuser.net/u/admin1)\
**Post date:** [September 24, 2013, 10:27am UTC](https://www.dynamicsuser.net/t/query-on-making-excel-sheet-of-a-report/48350/6 "2013-09-24T10:27:18Z")

</div>

Well then I suggest that you split this function into two: a MakeExcelHeader and a MakeExcelDataBody, so that you can make sure only to call the header once!

---

<div class="post-metadata">

**Author:** ![Priya\_Singh](https://avatars.discourse-cdn.com/v4/letter/p/c57346/32.png) [@Priya\_Singh](https://www.dynamicsuser.net/u/Priya_Singh)\
**Post date:** [September 24, 2013, 10:36am UTC](https://www.dynamicsuser.net/t/query-on-making-excel-sheet-of-a-report/48350/7 "2013-09-24T10:36:40Z")

</div>

Ya i did the same what you told me to do,i made two functions MakeExcelDataBody anf MakeExcelDataBody1 and i write the header code in MakeExcelDataBody and the body part in MakeExceldataBody1.but the output is same.

---

<div class="post-metadata">

**Author:** ![mohana\_cse06](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@mohana\_cse06](https://www.dynamicsuser.net/u/mohana_cse06)\
**Post date:** [September 24, 2013, 10:45am UTC](https://www.dynamicsuser.net/t/query-on-making-excel-sheet-of-a-report/48350/8 "2013-09-24T10:45:24Z")

</div>

Call MakeExcelDataBody function in OnPreDataitem trigger and MakeExcelDataBody1 in OnAfterGetRecord trigger.

---

<div class="post-metadata">

**Author:** ![Priya\_Singh](https://avatars.discourse-cdn.com/v4/letter/p/c57346/32.png) [@Priya\_Singh](https://www.dynamicsuser.net/u/Priya_Singh)\
**Post date:** [September 24, 2013, 10:48am UTC](https://www.dynamicsuser.net/t/query-on-making-excel-sheet-of-a-report/48350/9 "2013-09-24T10:48:58Z")

</div>

Thanku so much,now it works correctly.thanku to all of you
