Excel export server error

I’ve recently upgraded our Gantt and noticed that our excel export is now failing. We’re using the DHTMLX hosted service rather than our own, but it’s just loading a blank page and giving a 500 server error on the request. No other information is given.

Our code handling the export is

gantt.exportToExcel({
        name: "document.xlsx",
        columns: [
          { id: "text", header: "Title" },
          { id: "start_date", header: "Start date", type: "date" },
          { id: "end_date", header: "Deadline", type: "date" }
        ],
        visual: true,
        cellColors: true,
        date_format: "dddd d, mmmm yyyy"
      });

I’ve narrowed it down to the visual: true. If I remove this, then it exports correctly but the moment it is true it fails.

Sorry I can’t be much more help, but I’m not getting any feedback

Hello,
There are different reasons why it is happening. Most of them are related to the bug that the export module doesn’t know where to place the task bars.
It can happen if you change the zoom level, modify the scale settings, change the duration_unit to hour, make the tasks start or end not at 00:00, or maybe to something else.
There are different workarounds depending on your data and configuration.

Please add your data (you can remove the text, but you need to keep the dates) and Gantt configuration to the following snippet and make sure that the issue is reproduced:
http://snippet.dhtmlx.com/5/ad72d476b
Then click on the Share button and send me the link. I will check it and share the workaround.

The dev team will fix the bug in the future, but I cannot give you any ETA.

Hi,

Thanks for the response, it gives me some areas to look at. I’ve produced the snippet here http://snippet.dhtmlx.com/5/2d1694820 and whilst doing it, found that it’s exactly as you suggest - the zoom scale settings.

We’ve got customised formatting of the zoom scale which is breaking it. Before I added the config to that snippet it was exporting, but the moment I added it, it broke. So my next question then - is there a way of having a different zoom scale config for the export and the gantt itself so I can keep what we’ve got for the gantt, but still have working exports?

Hello,
If you only have a different zoom level, you can add the default scales before exporting the data, then revert the changes:
http://snippet.dhtmlx.com/5/9f63baa43

If you use the zoom extension and change the gantt.config.scales parameter, you only redefine the actual scales, but the zoom settings don’t change. That’s why you can obtain the current zoom level and reset it.

Ah that’s perfect thanks! Are there any limitations on what can be used for the scales so I can still potentially customise it slightly?

Hello,
The issue itself occurs because, for some scales, the tasks start or end with the non-integer value. As long as they start and end at the beginning or end of the day, it should work correctly.
So, you can try experimenting with the different scale settings and the source code of the export module.

hm they should already all be starting at the beginning/end of a day but I’ll have a play and see what works. Is it possibly also related to there being two rows for the scale headers? On the gantt we have it displaying the month in one row, and then the day numbers below that.

Hello,
I checked that it exports correctly when there is only the month scale and forced tasks to start at the beginning of the month.
So, it seems that it is related to both several scales and when the task doesn’t start at the beginning of the scale cell.

Brilliant thanks for this, I’ll have a play around