title: Export SVG image to Excel using javascript
body: <p>I'm using the Highchart library and its module <a href="http://www.highcharts.com/plugin-registry/single/7/Export%20Data" rel="nofollow noreferrer">(export-csv)</a> to export chart to excel.</p>
  
  <p>I get SVG chart data (chart.getSVG()), and then modify export-csv module: </p>
  
  <pre><code>Highcharts.Chart.prototype.downloadXLS = function () {
      var svg = this.getSVG();
      var dataUrl = 'data:image/svg+xml,'+encodeURIComponent(svg);
  
      var uri = 'data:application/vnd.ms-excel;base64,',
          template = '&lt;html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"&gt;' +
              '&lt;head&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;&lt;x:ExcelWorkbook&gt;&lt;x:ExcelWorksheets&gt;&lt;x:ExcelWorksheet&gt;' +
              '&lt;x:Name&gt;Ark1&lt;/x:Name&gt;' +
              '&lt;x:WorksheetOptions&gt;&lt;x:DisplayGridlines/&gt;&lt;/x:WorksheetOptions&gt;&lt;/x:ExcelWorksheet&gt;&lt;/x:ExcelWorksheets&gt;&lt;/x:ExcelWorkbook&gt;&lt;/xml&gt;&lt;![endif]--&gt;' +
              '&lt;style&gt;td{border:none;font-family: Calibri, sans-serif;} .number{mso-number-format:"0.00";}&lt;/style&gt;' +
              '&lt;meta name=ProgId content=Excel.Sheet&gt;' +
              '&lt;meta charset=UTF-8&gt;' +
              '&lt;/head&gt;&lt;body&gt;' +
              this.getTable(true) +
              '&lt;img src="'+dataUrl+'" alt="file.png"/&gt;'+
              '&lt;/body&gt;&lt;/html&gt;',
          base64 = function (s) { 
              return window.btoa(unescape(encodeURIComponent(s))); // #50
          };
      getContent(
          this,
          uri + base64(template),
          'xls',
          template,
          'application/vnd.ms-excel'
      );
  };
  </code></pre>
  
  <p>Using SVG data: </p>
  
  <pre><code>var svg = this.getSVG();
  </code></pre>
  
  <p>We generate a URL image:</p>
  
  <pre><code>var dataUrl = 'data:image/svg+xml,'+encodeURIComponent(svg);
  </code></pre>
  
  <p>And add that URL to the excel body:</p>
  
  <pre><code>  '&lt;img src="'+dataUrl+'" alt="file.png"/&gt;'+
  </code></pre>
  
  <p>But I can not export the image</p>
  
  <p>any ideas?</p>
  
  <p>THANKS!!</p>