dcothran
Posts: 4
Joined: Mon Jun 17, 2019 1:55 pm

Keep Subtitle in .XLS Download

My charts have subtitles, and when I download an image, the subtitle is included in the download. However, when I download as a .XLS file, the subtitle disappears. The subtitle contains critical information, so I do not want it to disappear.

How can I retain the subtitle in a .XLS download?
rafalS
Site Moderator
Posts: 2675
Joined: Thu Jun 14, 2018 11:40 am

Re: Keep Subtitle in .XLS Download

Hi dcothran,

Welcome to our forum and thanks for contacting us.

I wrapped a method responsible for table generating and it's generating both title and subtitle now.
But, when I open exported .XLS file in Excel, the subtitle isn't nicely centered like the title. I think it's a limitation of excel or .XLS format that allows having only one header nicely styled, but I'm just guessing.

Here is an example for you: https://jsfiddle.net/BlackLabel/vtyeqb0j

Take a look at it and let me know what do you think or you have any further questions.

Best regards!
Rafal Sebestjanski,
Highcharts Team Lead
dcothran
Posts: 4
Joined: Mon Jun 17, 2019 1:55 pm

Re: Keep Subtitle in .XLS Download

Thanks, this is working, except the subtitle is currently the first row and the title is second, which should be reversed. But still a big improvement. Will any of this code be incorporated into the exporting.js file?
rafalS
Site Moderator
Posts: 2675
Joined: Thu Jun 14, 2018 11:40 am

Re: Keep Subtitle in .XLS Download

dcothran,

You can simply correct it in the code or you can swap subtitle with title in your chart options. I had a reason why I left it this way, but, to be honest, I don't remember why now... ;)

We don't have plans for adding this functionality to the core right now, but you can create a ticket on our UserVoice channel here: https://highcharts.uservoice.com
We will keep it noticed and implement as soon as it gets some more votes.

Best regards!
Rafal Sebestjanski,
Highcharts Team Lead
dcothran
Posts: 4
Joined: Mon Jun 17, 2019 1:55 pm

Re: Keep Subtitle in .XLS Download

Thanks for that link, Rafal! However, for switching the order of the title and subtitle, this is a little more tricky for me, as I am using software that generates both of these options for me, and there are special features on the title field that I need. Is there any adjustment to the code you sent that I could make to switch the order? I was reading through it, but I didn't see anywhere that this could be done, but I'm also not much of a JS dev.
rafalS
Site Moderator
Posts: 2675
Joined: Thu Jun 14, 2018 11:40 am

Re: Keep Subtitle in .XLS Download

Sure, here you go: https://jsfiddle.net/BlackLabel/rn4txebf

I just swapped title with subtitle here:

Code: Select all

// Add table caption
    if (options.exporting.tableCaption !== false) {
      html += '<caption class="highcharts-table-caption">' + H.pick(
        options.exporting.tableCaption,
        (
          options.subtitle.text ?
          htmlencode(options.subtitle.text) :
          'Chart'
        )
      ) + '</caption>';
      html += '<caption class="highcharts-table-caption">' + H.pick(
        options.exporting.tableCaption,
        (
          options.title.text ?
          htmlencode(options.title.text) :
          'Chart'
        )
      ) + '</caption>';
    }

Regards.
Rafal Sebestjanski,
Highcharts Team Lead
dcothran
Posts: 4
Joined: Mon Jun 17, 2019 1:55 pm

Re: Keep Subtitle in .XLS Download

Perfect--thank you!

Return to “Highcharts Usage”