# Export file using predefined export in a wizard

**URL:** https://discuss.tryton.org/t/export-file-using-predefined-export-in-a-wizard/6468
**Category:** Developer
**Created:** [August 25, 2023, 6:29am UTC](https://discuss.tryton.org/t/export-file-using-predefined-export-in-a-wizard/6468 "2023-08-25T06:29:07Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![shervas](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/s/a3d4f5/32.png) [@shervas](https://discuss.tryton.org/u/shervas)
#### Post date: [August 25, 2023, 6:29am UTC](https://discuss.tryton.org/t/export-file-using-predefined-export-in-a-wizard/6468/1 "2023-08-25T06:29:08Z")

</div>

HI,  
I have a wizard that when it’s executed it lists records of a ModelView class. It’s looks quite similar to the Bom Tree relate of a product.  
And what I want is that when you pass to another transition called “Export”, an xlsx file is generated with the same information that was listed. To do that, I would like to use the predefined export or if it should be done by another way, another.  
Thanks beforehand.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [August 25, 2023, 6:34am UTC](https://discuss.tryton.org/t/export-file-using-predefined-export-in-a-wizard/6468/2 "2023-08-25T06:34:43Z")

</div>

> [@shervas](#):
>
> And what I want is that when you pass to another transition called “Export”, an xlsx file is generated with the same information that was listed. To do that, I would like to use the predefined export or if it should be done by another way, another.

You can use the [export\_data](https://docs.tryton.org/projects/server/en/latest/ref/models.html#trytond.model.ModelStorage.export_data) function to get the data related to the export and generate the xlsx file using [openpyxl](https://pypi.org/project/openpyxl/).

If you want to reuse a predefined export, you should load the field names from the `ir.export` model.

I’m recomending this function because this is the one called by the clients when exporting data.

---

<div class="post-metadata">

### Author: ![shervas](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/s/a3d4f5/32.png) [@shervas](https://discuss.tryton.org/u/shervas)
#### Post date: [August 25, 2023, 7:50am UTC](https://discuss.tryton.org/t/export-file-using-predefined-export-in-a-wizard/6468/3 "2023-08-25T07:50:15Z")

</div>

> [@pokoli](#):
>
> You can use the [export\_data](https://docs.tryton.org/projects/server/en/latest/ref/models.html#trytond.model.ModelStorage.export_data) function to get the data related to the export and generate the xlsx file using [openpyxl](https://pypi.org/project/openpyxl/).

I can’t call export\_data function cause I’m not inhereting ModelStorage.

> [@pokoli](#):
>
> If you want to reuse a predefined export, you should load the field names from the `ir.export` model.

How can I do that?

---

<div class="post-metadata">

### Author: ![shervas](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/s/a3d4f5/32.png) [@shervas](https://discuss.tryton.org/u/shervas)
#### Post date: [August 28, 2023, 11:22am UTC](https://discuss.tryton.org/t/export-file-using-predefined-export-in-a-wizard/6468/4 "2023-08-28T11:22:04Z")

</div>

Finally, I did it using a Binary field and filling it in the wizard in a new StateView.

> [@File downloader wizard](https://discuss.tryton.org/t/file-downloader-wizard/1793):
>
> Hello, I’d like to create a wizard that provide a file users can download, something like in the export wizard. I didn’t find it in the docs, how can I tell Tryton send a file to an user ? Thanks

---

<div class="post-metadata">

### Author: ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)
#### Post date: [August 28, 2023, 11:22pm UTC](https://discuss.tryton.org/t/export-file-using-predefined-export-in-a-wizard/6468/5 "2023-08-28T23:22:30Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
