圖表是展示資訊時的重要組成部分。當事實和數據有適當且相應的圖形、圖表或表格做支持時,在 PPT 中所呈現的信息變得更強大且具有影響力。這些圖形、圖表或表格除了具有極大的視覺吸引力之外,還能以有序的方式向目標受眾傳遞相關的商業資訊。在本文中,我們將討論使用 REST API 在 PowerPoint 中創建或修改圖表的步驟。

資訊:Aspose 提供一個免費的 PowerPoint to PDF converter,可以讓您將簡報轉換為 PDF。

在 PPT 中使用圖表的好處

我們可以從在 PPT 中以不同的圖形、圖表或表格呈現數據中獲得許多好處:

  1. 圖形、圖表、圖示或表格以簡潔、一致且緊湊的風格呈現資訊。目標受眾能快速理解數據的含義。
  2. 它們在視覺上比純文字內容更具吸引力。並且您的 PPT 在正確的整合下自動變得更加引人入勝。
  3. 觀眾總是希望從幻燈片中得到一些結論,這有助於理解演示的核心結論。
  4. 透過視覺模式進行不同數據和數字的比較,使事實的評估變得更加容易。
  5. 更多的事可以被提及,更多的事實可以被容納並以簡潔的方式排列,這就是 PPT 中圖表的美。
  6. 他們幫助您的潛在客戶在不同可理解的參數上對您業務的各個細節做出重要推斷。

PowerPoint 處理 API

Aspose.Slides Cloud 是一個基於 REST 的 API,提供創建和操作 PowerPoint 和 OpenOffice 演示文件的功能。在最近的發佈版本中,新的資源是一個形狀的子資源。它僅適用於圖表形狀,並允許我們添加、修改和刪除圖表系列。

將系列加入圖表

POST https://api.aspose.cloud/v3.0/slides/myPresentaion.pptx/slides/1/shapes/1/series?folder=myFolder

請求主體

{ "dataPointType": "OneValue", "dataPoints": [{ "value": 5.5</code> <code>}, { "value": 76</code> <code>}, { "value": 27</code> <code>}] }
string MyAppKey = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/

SlidesApi api = new SlidesApi("MyAppSid", "MyAppKey");
OneValueSeries dto = new OneValueSeries();
dto.DataPoints = new List<OneValueChartDataPoint>();
dto.DataPoints.Add(new OneValueChartDataPoint { Value = 5.5 });
dto.DataPoints.Add(new OneValueChartDataPoint { Value = 76 });
dto.DataPoints.Add(new OneValueChartDataPoint { Value = 27 });
PostChartSeriesRequest request = new PostChartSeriesRequest
{
    Name = "myPresentaion.pptx",
    Folder = "myFolder",
    SlideIndex = 1,
    ShapeIndex = 1,
    Series = dto
};
Chart chart = api.PostChartSeries(request);
Console.WriteLine(chart.Series.Count);

更新圖表系列

PUT https://api.aspose.cloud/v3.0/slides/myPresentaion.pptx/slides/1/shapes/1/series/2?folder=myFolder

請求主體

{ "dataPointType": "OneValue", "dataPoints": [{ "value": 5.5</code> <code>}, { "value": 76</code> <code>}, { "value": 27</code> <code>}] }
string MyAppKey = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/

SlidesApi api = new SlidesApi("MyAppSid", "MyAppKey");
OneValueSeries dto = new OneValueSeries();
dto.DataPoints = new List<OneValueChartDataPoint>();
dto.DataPoints.Add(new OneValueChartDataPoint { Value = 5.5 });
dto.DataPoints.Add(new OneValueChartDataPoint { Value = 76 });
dto.DataPoints.Add(new OneValueChartDataPoint { Value = 27 });
PutChartSeriesRequest request = new PutChartSeriesRequest
{
    Name = "myPresentaion.pptx",
    Folder = "myFolder",
    SlideIndex = 1,
    ShapeIndex = 1,
    SeriesIndex = 2,
    Series = dto
};
Chart chart = api.PutChartSeries(request);
Console.WriteLine(((OneValueSeries)chart.Series[1]).DataPoints.Count);

刪除圖表系列

DELETE https://api.aspose.cloud/v3.0/slides/myPresentaion.pptx/slides/1/shapes/1/series/2?folder=myFolder
string MyAppKey = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxx";    // Get AppKey and AppSID from https://dashboard.aspose.cloud/

SlidesApi api = new SlidesApi("MyAppSid", "MyAppKey");
DeleteChartSeriesRequest request = new DeleteChartSeriesRequest
{
    Name = "myPresentaion.pptx",
    Folder = "myFolder",
    SlideIndex = 1,
    ShapeIndex = 1,
    SeriesIndex = 2
};
Chart chart = api.DeleteChartSeries(request);
Console.WriteLine(chart.Series.Count);

相關文章

我們也建議您訪問以下鏈接以了解更多有關: