Home Forums Chart Support Export chart to excel and edit data in excel to see changes in chart in excel? Reply To: Export chart to excel and edit data in excel to see changes in chart in excel?

#24428

@venkateshganu,

It is possible to export the chart data in CSV format, but rendering and updating the chart within excel is not possible as of now. Please check the below code snippet to convert chart data into comma-separated CSV –

function convertChartDataToCSV(args) {  
  var result, ctr, keys, columnDelimiter, lineDelimiter, data;

  data = args.data || null;
  if (data == null || !data.length) {
    return null;
  }

  columnDelimiter = args.columnDelimiter || ',';
  lineDelimiter = args.lineDelimiter || '\n';

  keys = Object.keys(data[0]);

  result = '';
  result += keys.join(columnDelimiter);
  result += lineDelimiter;

  data.forEach(function(item) {
    ctr = 0;
    keys.forEach(function(key) {
      if (ctr > 0) result += columnDelimiter;
      result += item[key];
      ctr++;
    });
    result += lineDelimiter;
  });
  return result;
}

Kindly take a look at this JSFiddle for a fully functional example on exporting chart data as CSV. Also take a look at this plugin, which does the same.

exporting chart data as csv

___________
Indranil Deo
Team CanvasJS