# system.dataset.dataSetToExcel OutOfMemoryError

**URL:** <https://forum.inductiveautomation.com/t/system-dataset-datasettoexcel-outofmemoryerror/39363>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [October 5, 2020, 8:30am UTC](https://forum.inductiveautomation.com/t/system-dataset-datasettoexcel-outofmemoryerror/39363 "2020-10-05T08:30:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gianlucab](https://avatars.discourse-cdn.com/v4/letter/g/74df32/32.png) [@gianlucab](https://forum.inductiveautomation.com/u/gianlucab)\
**Post date:** [October 5, 2020, 8:30am UTC](https://forum.inductiveautomation.com/t/system-dataset-datasettoexcel-outofmemoryerror/39363/1 "2020-10-05T08:30:21Z")

</div>

Hello to all,  
I have a problem with system.dataset.dataSetToExcel. I need to export big data from a table. In my vision application I have some table where I can see the data and I have create a button to export all the table. But the table with few data don't have problem when I export the table with many data after a lug I get the error "java.lang.OutOfMemoryError: java.lang.OutOfMemoryError: Java heap space".  
I tried to export using dataSetToCSV the same data and it work very well and very fast but if is possible exporting to excel would be more convenient. Anyone have same problem o some ideas?

This i my code:

> spreadsheet = system.dataset.toExcel(True, [ctbgrezzi.data])  
> filePath = system.file.saveFile("grezzi.csv")  
> #spreadsheet = system.dataset.toCSV(ctbgrezzi.data)  
> #filePath = system.file.saveFile("grezzi.csv","csv","Comma separated values")  
> if filePath != None:  
> system.file.writeFile(filePath, spreadsheet)

Traceback (most recent call last):  
File "event:mouseClicked", line 19, in   
java.lang.OutOfMemoryError: java.lang.OutOfMemoryError: Java heap space

```
caused by OutOfMemoryError: Java heap space

```

Ignition v8.0.16 (b2020082513)  
Java: Azul Systems, Inc. 11.0.7

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 5, 2020, 10:48am UTC](https://forum.inductiveautomation.com/t/system-dataset-datasettoexcel-outofmemoryerror/39363/2 "2020-10-05T10:48:03Z")

</div>

Did you try allocating more memory to the client?

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [October 5, 2020, 12:03pm UTC](https://forum.inductiveautomation.com/t/system-dataset-datasettoexcel-outofmemoryerror/39363/3 "2020-10-05T12:03:58Z")

</div>

Can you do this in chunks? I don’t know what is forming your `ctbgrezzi.data` variable, if its always going to be 10,000 rows no matter what, more ram will do the trick, but if its a table that is going to keep getting longer, you should try to refactor your code now to do it in chunks imo.

---

<div class="post-metadata">

**Author:** ![gianlucab](https://avatars.discourse-cdn.com/v4/letter/g/74df32/32.png) [@gianlucab](https://forum.inductiveautomation.com/u/gianlucab)\
**Post date:** [October 5, 2020, 12:06pm UTC](https://forum.inductiveautomation.com/t/system-dataset-datasettoexcel-outofmemoryerror/39363/4 "2020-10-05T12:06:18Z")

</div>

Thank you for the reply. More memory solve the problem but there is no way to find a solution with a limited resource request?  
The “toCSV” function works immediatly without memory problem. The toExcel function take a lot of seconds and in case of a lot of data cause memory problem with limited resource. If there is no way to optimize the toExcel function I think I will use the CSV exportation.  
Thanks

---

<div class="post-metadata">

**Author:** ![gianlucab](https://avatars.discourse-cdn.com/v4/letter/g/74df32/32.png) [@gianlucab](https://forum.inductiveautomation.com/u/gianlucab)\
**Post date:** [October 5, 2020, 12:19pm UTC](https://forum.inductiveautomation.com/t/system-dataset-datasettoexcel-outofmemoryerror/39363/5 "2020-10-05T12:19:09Z")

</div>

Thank you for the reply,  
ctbgrezzi.data is a stored value for generating a certificate. In this case I used 4000 rows X 70 cols.  
The maximun size of this registration can be about 16000rowsx70cols  
Chunks is a possibility but not so friendly for the enduser.  
Thanks

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [October 5, 2020, 1:32pm UTC](https://forum.inductiveautomation.com/t/system-dataset-datasettoexcel-outofmemoryerror/39363/6 "2020-10-05T13:32:14Z")

</div>

> [@gianlucab](#):
>
> More memory solve the problem but there is no way to find a solution with a limited resource request?

Converting a dataset to excel is more memory intensive than converting it to csv, because the converted data is larger. Since it stays in memory until the end, more memory is required to do the operation.

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [October 5, 2020, 2:15pm UTC](https://forum.inductiveautomation.com/t/system-dataset-datasettoexcel-outofmemoryerror/39363/7 "2020-10-05T14:15:05Z")

</div>

What Jordan said is exactly right. The conversion to Excel takes a _lot_ more processing than CSV – setting datatypes and formatting, autosizing columns, etc, which are all done in memory. As the number of cells increase in your worksheet, the amount of memory needed grows very quickly.

I took a quick look at the code and it looks pretty optimized, so unfortunately more memory is the way you need to go here.

---

<div class="post-metadata">

**Author:** ![gianlucab](https://avatars.discourse-cdn.com/v4/letter/g/74df32/32.png) [@gianlucab](https://forum.inductiveautomation.com/u/gianlucab)\
**Post date:** [October 6, 2020, 2:02pm UTC](https://forum.inductiveautomation.com/t/system-dataset-datasettoexcel-outofmemoryerror/39363/8 "2020-10-06T14:02:22Z")

</div>

Thank you for the reply,  
I try to check the better way to my project.  
Thank you very much
