# Export an  file from Ax 2009.

**URL:** <https://www.dynamicsuser.net/t/export-an-file-from-ax-2009/62121>\
**Category:** User Forum\
**Created:** [November 29, 2016, 12:07pm UTC](https://www.dynamicsuser.net/t/export-an-file-from-ax-2009/62121 "2016-11-29T12:07:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![VaibhavA](https://avatars.discourse-cdn.com/v4/letter/v/eada6e/32.png) [@VaibhavA](https://www.dynamicsuser.net/u/VaibhavA)\
**Post date:** [November 29, 2016, 12:07pm UTC](https://www.dynamicsuser.net/t/export-an-file-from-ax-2009/62121/1 "2016-11-29T12:07:33Z")

</div>

Hi All

I want to export records from custTable to .csv file and want that my code will run on server side.

How I can achieve this using Classes.

Regards

Vaibhav Agrawal

---

<div class="post-metadata">

**Author:** ![SarathKumar](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@SarathKumar](https://www.dynamicsuser.net/u/SarathKumar)\
**Post date:** [November 29, 2016, 12:17pm UTC](https://www.dynamicsuser.net/t/export-an-file-from-ax-2009/62121/2 "2016-11-29T12:17:30Z")

</div>

Im not sure with my answer.Just try this…

CommaIo file= new CommaIo(FilePath+“filename.csv”,“w”);

container buffer;

DictTable dt = new DictTable(tableNum(YOURTABLE));

int fieldcount;

for (fieldcount =1 ;fieldcount \<= dt.fieldCnt();fieldcount++)

{

buffer += [dt.fieldName(dt.fieldCnt2Id(fieldcount))];

}

file.writeExp(buffer);

while select YOURTABLE

{

buffer = ConNull();

for (fieldcount =1 ;fieldcount \<= dt.fieldCnt();fieldcount++)

{

buffer +=[YOURTABLE.(dt.fieldCnt2Id(fieldcount))];

}

file.writeExp(buffer);

}

file.finalize();

---

<div class="post-metadata">

**Author:** ![SarathKumar](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@SarathKumar](https://www.dynamicsuser.net/u/SarathKumar)\
**Post date:** [November 29, 2016, 12:18pm UTC](https://www.dynamicsuser.net/t/export-an-file-from-ax-2009/62121/3 "2016-11-29T12:18:19Z")

</div>

[mfmujahidmim.wordpress.com/…/](https://mfmujahidmim.wordpress.com/2015/12/04/how-to-export-table-data-in-to-csv-file-in-ax-2012/)

---

<div class="post-metadata">

**Author:** ![SarathKumar](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@SarathKumar](https://www.dynamicsuser.net/u/SarathKumar)\
**Post date:** [November 29, 2016, 12:33pm UTC](https://www.dynamicsuser.net/t/export-an-file-from-ax-2009/62121/4 "2016-11-29T12:33:58Z")

</div>

[alfasith.blogspot.in/…/job-class-code-to-import-csv-excel-file.html](http://alfasith.blogspot.in/2013/10/job-class-code-to-import-csv-excel-file.html)

---

<div class="post-metadata">

**Author:** ![KARTHIK\_M](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@KARTHIK\_M](https://www.dynamicsuser.net/u/KARTHIK_M)\
**Post date:** [November 29, 2016, 1:18pm UTC](https://www.dynamicsuser.net/t/export-an-file-from-ax-2009/62121/5 "2016-11-29T13:18:10Z")

</div>

.CSV file means we can do in Job but Server side u should do with Morphix report

[msdn.microsoft.com/…/cc967382(v=ax.50).aspx](https://msdn.microsoft.com/en-us/library/cc967382(v=ax.50).aspx)

try it
