# To Excel as xlsx?

**URL:** <https://forum.inductiveautomation.com/t/to-excel-as-xlsx/41860>\
**Category:** Ignition\
**Tags:** namedqueries, scripting\
**Created:** [December 30, 2020, 4:32pm UTC](https://forum.inductiveautomation.com/t/to-excel-as-xlsx/41860 "2020-12-30T16:32:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cfuta](https://avatars.discourse-cdn.com/v4/letter/c/da6949/32.png) [@cfuta](https://forum.inductiveautomation.com/u/cfuta)\
**Post date:** [December 30, 2020, 4:32pm UTC](https://forum.inductiveautomation.com/t/to-excel-as-xlsx/41860/1 "2020-12-30T16:32:19Z")

</div>

I am currently running a named query that gets exported to excel using system.dataset.exportExcel which works but can only currently export as an xls file. Is there a work around to export as xlsx file?

---

<div class="post-metadata">

**Author:** ![osolorzano](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/osolorzano/32/6432_2.png) [@osolorzano](https://forum.inductiveautomation.com/u/osolorzano)\
**Post date:** [December 30, 2020, 6:52pm UTC](https://forum.inductiveautomation.com/t/to-excel-as-xlsx/41860/2 "2020-12-30T18:52:20Z")

</div>

As of 8.0.7, system.dataset.toExcel() and system.dataset.exportExcel() have support for and default to xlsx. If you are on that version or higher you just need to make sure you are saving the file with the xlsx extension.

---

<div class="post-metadata">

**Author:** ![Sean\_OBrien](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sean_obrien/32/32232_2.png) [@Sean\_OBrien](https://forum.inductiveautomation.com/u/Sean_OBrien)\
**Post date:** [February 25, 2022, 10:03pm UTC](https://forum.inductiveautomation.com/t/to-excel-as-xlsx/41860/3 "2022-02-25T22:03:01Z")

</div>

do you have an example of this code, i’m currently trying to do this and cant figure it out. Here is my code

table =system.db.runNamedQuery(“DailyRunQ”, {})  
import time  
timestr = time.strftime("%Y.%m.%d")  
print timestr

from os.path import expanduser  
home = expanduser("~")

filePath = system.dataset.exportExcel(home + “\Documents\CIP Consumption Data\” + timestr + “.Consumption Data.xls”, 1, table.data)  
if filePath != None:

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [February 25, 2022, 10:08pm UTC](https://forum.inductiveautomation.com/t/to-excel-as-xlsx/41860/4 "2022-02-25T22:08:03Z")

</div>

> [@Sean\_OBrien](#):
>
> Consumption Data.xls

Try changing to `Consumption Data.xlsx`

Welcome to the form! PS, try to use preformatted text `</>` when posting your code.

---

<div class="post-metadata">

**Author:** ![Sean\_OBrien](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sean_obrien/32/32232_2.png) [@Sean\_OBrien](https://forum.inductiveautomation.com/u/Sean_OBrien)\
**Post date:** [February 25, 2022, 10:18pm UTC](https://forum.inductiveautomation.com/t/to-excel-as-xlsx/41860/5 "2022-02-25T22:18:26Z")

</div>

josborn,

Thank you for the response. The issue i’m having isn’t with the format .xls vs .xlsx,

What i’m not able to get to do is get the named query database to execute and then save into the xls at all. I am completely new to this environment and coding in general, so I was hoping to see how user cfuta was able to get his code setup to execute a named query and save to an excel sheet

---

<div class="post-metadata">

**Author:** ![Sean\_OBrien](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sean_obrien/32/32232_2.png) [@Sean\_OBrien](https://forum.inductiveautomation.com/u/Sean_OBrien)\
**Post date:** [February 25, 2022, 10:30pm UTC](https://forum.inductiveautomation.com/t/to-excel-as-xlsx/41860/6 "2022-02-25T22:30:27Z")

</div>

i got it, i was trying to call it into a table instead of just having the export function pull it directly. Thank you!
