SharePoint how to export chart to Excel

Sevil Red 101 Reputation points
2021-02-02T14:00:39.18+00:00

Good day,

I have the script to show ViewsLastMonths2 and ViewsLastMonths2Unique on SP 2016 page. I show ViewsLastMonths2 on diagram by Chart.js https://www.chartjs.org/

I export ViewsLastMonths2 data to Excel. But I can't export the Chart to excel.

How can I show in Excel file ? This information didn't help https://learn.microsoft.com/en-us/office/dev/add-ins/excel/excel-add-ins-charts

My script63092-codeexample1.txt

Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

Accepted answer
  1. MichaelHan-MSFT 18,126 Reputation points
    2021-02-03T08:53:37.83+00:00

    Hi @Sevil Red ,

    To export the Chart to Excel, you could try this way;

    var rang = oSheet.Range("A1:C10");  
    var ch = oSheet.ChartObjects().Add(rang.Left +   
    rang.Width, rang.Top, 350, 220);  
    ch.Chart.ChartType = 4;  
    ch.Chart.SetSourceData(rang, 2);  
    

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.