<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to export tables in dashboard to Excel format using JavaScript? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-export-tables-in-dashboard-to-Excel-format-using/m-p/432480#M28519</link>
    <description>&lt;P&gt;Hi @marxsabandana &lt;/P&gt;

&lt;P&gt;Please refer this question (the requirements was almost similar) and see if it helps:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/749857/how-to-make-a-second-download-button.html#answer-749318"&gt;https://answers.splunk.com/answers/749857/how-to-make-a-second-download-button.html#answer-749318&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I have provided an example of csv file. But you can try to change the format to xls and see if that works.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jun 2019 09:24:48 GMT</pubDate>
    <dc:creator>pramit46</dc:creator>
    <dc:date>2019-06-18T09:24:48Z</dc:date>
    <item>
      <title>How to export tables in dashboard to Excel format using JavaScript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-export-tables-in-dashboard-to-Excel-format-using/m-p/432478#M28517</link>
      <description>&lt;P&gt;I got this code from CodexWorld(dot)com. How can I integrate this in a Splunk dashboard?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; function exportTableToExcel(tableID, filename = ''){
        var downloadLink;
        var dataType = 'application/vnd.ms-excel';
        var tableSelect = document.getElementById(tableID);
        var tableHTML = tableSelect.outerHTML.replace(/ /g, '%20');

        // Specify file name
        filename = filename?filename+'.xls':'excel_data.xls';

        // Create download link element
        downloadLink = document.createElement("a");

        document.body.appendChild(downloadLink);

        if(navigator.msSaveOrOpenBlob){
            var blob = new Blob(['\ufeff', tableHTML], {
                type: dataType
            });
            navigator.msSaveOrOpenBlob( blob, filename);
        }else{
            // Create a link to the file
            downloadLink.href = 'data:' + dataType + ', ' + tableHTML;

            // Setting the file name
            downloadLink.download = filename;

            //triggering the function
            downloadLink.click();
        }
    }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then I put a button wrapped in an html tag, with putting an id in my table like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;html&amp;gt;
&amp;lt;button class="btn btn-primary" onclick="exportTableToExcel('tableid1', 'file-name')"&amp;gt;Export Table Data To Excel File&amp;lt;/button&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I also already tried using the Excel Export app at Splunkbase but I need to modify the code, to make the table headers in bold font weight and have dynamic column size depending on the text length of each headers.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 07:57:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-export-tables-in-dashboard-to-Excel-format-using/m-p/432478#M28517</guid>
      <dc:creator>marxsabandana</dc:creator>
      <dc:date>2019-06-18T07:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to export tables in dashboard to Excel format using JavaScript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-export-tables-in-dashboard-to-Excel-format-using/m-p/432479#M28518</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;you have to create a javascript file in App/appserver/static/your_script_name.js.&lt;/P&gt;

&lt;P&gt;this file has to contain this:&lt;/P&gt;

&lt;P&gt;require([&lt;BR /&gt;
        "splunkjs/mvc/simplexml/ready!"&lt;BR /&gt;
], function() {&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;PUT YOUR CODE HERE&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;});&lt;/P&gt;

&lt;P&gt;To reference this javascript file in your dashboard, you have to add it the header of the dashboard like this:&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:59:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-export-tables-in-dashboard-to-Excel-format-using/m-p/432479#M28518</guid>
      <dc:creator>at1ll3y</dc:creator>
      <dc:date>2020-09-30T00:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to export tables in dashboard to Excel format using JavaScript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-export-tables-in-dashboard-to-Excel-format-using/m-p/432480#M28519</link>
      <description>&lt;P&gt;Hi @marxsabandana &lt;/P&gt;

&lt;P&gt;Please refer this question (the requirements was almost similar) and see if it helps:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/749857/how-to-make-a-second-download-button.html#answer-749318"&gt;https://answers.splunk.com/answers/749857/how-to-make-a-second-download-button.html#answer-749318&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I have provided an example of csv file. But you can try to change the format to xls and see if that works.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 09:24:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-export-tables-in-dashboard-to-Excel-format-using/m-p/432480#M28519</guid>
      <dc:creator>pramit46</dc:creator>
      <dc:date>2019-06-18T09:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to export tables in dashboard to Excel format using JavaScript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-export-tables-in-dashboard-to-Excel-format-using/m-p/432481#M28520</link>
      <description>&lt;P&gt;Thanks. Will check on it now.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 09:39:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-export-tables-in-dashboard-to-Excel-format-using/m-p/432481#M28520</guid>
      <dc:creator>marxsabandana</dc:creator>
      <dc:date>2019-06-18T09:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to export tables in dashboard to Excel format using JavaScript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-export-tables-in-dashboard-to-Excel-format-using/m-p/432482#M28521</link>
      <description>&lt;P&gt;Did it help? Were you looking for anything else?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 07:23:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-export-tables-in-dashboard-to-Excel-format-using/m-p/432482#M28521</guid>
      <dc:creator>pramit46</dc:creator>
      <dc:date>2019-06-20T07:23:29Z</dc:date>
    </item>
  </channel>
</rss>

