91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

使用C# / VB.NET 實現在PPT中創建、編輯PPT SmartArt圖形

發布時間:2020-10-26 17:31:01 來源:億速云 閱讀:207 作者:Leah 欄目:開發技術

今天就跟大家聊聊有關使用C# / VB.NET 實現在PPT中創建、編輯PPT SmartArt圖形,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內容,希望大家根據這篇文章可以有所收獲。

Dll文件引用

方式1:下載包。下載后,解壓,打開Bin文件夾,根據自己用的.NET Framework選擇相應的文件夾,如:此示例中使用的是NET4.0,即打開NET4.0文件,找到Spire.Presentation.dll文件。找到dll文件后,在vs程序中添加引用該dll。

如下引用結果:

使用C# / VB.NET 實現在PPT中創建、編輯PPT SmartArt圖形

方式2:通過Nuget搜索下載導入。

注:創建SmartArt圖形時,可創建80多種不同類型的圖形,編輯圖形是,可添加、刪除節點、編輯節點內容、給節點內容設置超鏈接(包括鏈接到網頁、鏈接到幻燈片)

示例1. 創建PPT SmartArt圖形

using Spire.Presentation;
using Spire.Presentation.Diagrams;


namespace AddSmartArt
{
  class Program
  {
    static void Main(string[] args)
    {
      //實例化Presentation對象
      Presentation ppt = new Presentation();

      //設置幻燈片大小
      ppt.SlideSize.Type = SlideSizeType.Screen16x9;

      //添加組織結構圖類型的SmartArt圖形,并指定位置、大小
      ISmartArt smartArt = ppt.Slides[0].Shapes.AppendSmartArt(100, 50, 450, 250, SmartArtLayoutType.OrganizationChart);

      //設置SmartArt的樣式和顏色
      smartArt.Style = SmartArtStyleType.IntenceEffect;
      smartArt.ColorStyle = SmartArtColorType.ColorfulAccentColors3to4;

      //移除默認的形狀(Node即代表SmartArt中的形狀)
      foreach (ISmartArtNode node in smartArt.Nodes)
      {
        smartArt.Nodes.RemoveNode(node);
      }

      //添加形狀并在其下面添加嵌套子形狀
      ISmartArtNode node1 = smartArt.Nodes.AddNode();
      ISmartArtNode node1_1 = node1.ChildNodes.AddNode();
      ISmartArtNode node1_1_1 = node1_1.ChildNodes.AddNode();
      ISmartArtNode node1_1_2 = node1_1.ChildNodes.AddNode();
      ISmartArtNode node1_1_3 = node1_1.ChildNodes.AddNode();
      ISmartArtNode node1_1_4 = node1_1.ChildNodes.AddNode();
      ISmartArtNode node1_1_5 = node1_1.ChildNodes.AddNode();
      ISmartArtNode node1_1_6 = node1_1.ChildNodes.AddNode();
      ISmartArtNode node1_1_1_1 = node1_1_1.ChildNodes.AddNode();
      ISmartArtNode node1_1_1_2 = node1_1_1.ChildNodes.AddNode();
      ISmartArtNode node1_1_1_3 = node1_1_1.ChildNodes.AddNode();
      ISmartArtNode node1_1_3_1 = node1_1_3.ChildNodes.AddNode();
      ISmartArtNode node1_1_3_2 = node1_1_3.ChildNodes.AddNode();
      ISmartArtNode node1_1_6_1 = node1_1_6.ChildNodes.AddNode();
      ISmartArtNode node1_1_6_2 = node1_1_6.ChildNodes.AddNode();
      ISmartArtNode node1_1_6_3 = node1_1_6.ChildNodes.AddNode();
      

      //在每一個形狀上添加文字
      node1.TextFrame.Text = "董事會\n" + "Board of Directors";      
      node1_1.TextFrame.Text = "總經理\n" + "General Manager";
      node1_1_1.TextFrame.Text = "供應部\n" + "Supply Dept.";
      node1_1_2.TextFrame.Text = "營銷部\n" + "Sales Dept.";
      node1_1_3.TextFrame.Text = "生產部\n" + "Productive Dept.";
      node1_1_4.TextFrame.Text = "財務部\n" + "Finance Dept.";
      node1_1_5.TextFrame.Text = "人力資源部\n" + "HR Dept.";
      node1_1_6.TextFrame.Text = "質檢中心\n" + "Quality Center";
      node1_1_1_1.TextFrame.Text = "采購部\n" + "Purchase Dept.";
      node1_1_1_2.TextFrame.Text = "倉庫管理\n" + "Warehouse Manager";
      node1_1_1_3.TextFrame.Text = "物流部\n" + "Logistics Dept.";
      node1_1_3_1.TextFrame.Text = "生產車間\n" + "Production Dept.";
      node1_1_3_2.TextFrame.Text = "維修部\n" + "Maintenance Dept.";
      node1_1_6_1.TextFrame.Text = "生產質量管理\n" + "Production Quality Mgt.";
      node1_1_6_2.TextFrame.Text = "生產安全管理\n" + "Production Safety Mgt.";
      node1_1_6_3.TextFrame.Text = "環境管理\n" + "Environmental Mgt.";
      

      //保存文檔
      ppt.SaveToFile("result.pptx", FileFormat.Pptx2013);
      System.Diagnostics.Process.Start("result.pptx");
    }
  }
}

圖形創建結果:

使用C# / VB.NET 實現在PPT中創建、編輯PPT SmartArt圖形

VB.NET

Imports Spire.Presentation
Imports Spire.Presentation.Diagrams


Namespace AddSmartArt
  Class Program
    Private Shared Sub Main(args As String())
      '實例化Presentation對象
      Dim ppt As New Presentation()

      '設置幻燈片大小
      ppt.SlideSize.Type = SlideSizeType.Screen16x9

      '添加組織結構圖類型的SmartArt圖形,并指定位置、大小
      Dim smartArt As ISmartArt = ppt.Slides(0).Shapes.AppendSmartArt(100, 50, 750, 450, SmartArtLayoutType.OrganizationChart)

      '設置SmartArt的樣式和顏色
      smartArt.Style = SmartArtStyleType.IntenceEffect
      smartArt.ColorStyle = SmartArtColorType.ColorfulAccentColors3to4

      '移除默認的形狀(Node即代表SmartArt中的形狀)
      For Each node As ISmartArtNode In smartArt.Nodes
        smartArt.Nodes.RemoveNode(node)
      Next

      '添加形狀并在其下面添加嵌套子形狀
      Dim node1 As ISmartArtNode = smartArt.Nodes.AddNode()
      Dim node1_1 As ISmartArtNode = node1.ChildNodes.AddNode()
      Dim node1_1_1 As ISmartArtNode = node1_1.ChildNodes.AddNode()
      Dim node1_1_2 As ISmartArtNode = node1_1.ChildNodes.AddNode()
      Dim node1_1_3 As ISmartArtNode = node1_1.ChildNodes.AddNode()
      Dim node1_1_4 As ISmartArtNode = node1_1.ChildNodes.AddNode()
      Dim node1_1_5 As ISmartArtNode = node1_1.ChildNodes.AddNode()
      Dim node1_1_6 As ISmartArtNode = node1_1.ChildNodes.AddNode()
      Dim node1_1_1_1 As ISmartArtNode = node1_1_1.ChildNodes.AddNode()
      Dim node1_1_1_2 As ISmartArtNode = node1_1_1.ChildNodes.AddNode()
      Dim node1_1_1_3 As ISmartArtNode = node1_1_1.ChildNodes.AddNode()
      Dim node1_1_3_1 As ISmartArtNode = node1_1_3.ChildNodes.AddNode()
      Dim node1_1_3_2 As ISmartArtNode = node1_1_3.ChildNodes.AddNode()
      Dim node1_1_6_1 As ISmartArtNode = node1_1_6.ChildNodes.AddNode()
      Dim node1_1_6_2 As ISmartArtNode = node1_1_6.ChildNodes.AddNode()
      Dim node1_1_6_3 As ISmartArtNode = node1_1_6.ChildNodes.AddNode()


      '在每一個形狀上添加文字
      node1.TextFrame.Text = "董事會" & vbLf + "Board of Directors"
      node1_1.TextFrame.Text = "總經理" & vbLf + "General Manager"
      node1_1_1.TextFrame.Text = "供應部" & vbLf + "Supply Dept."
      node1_1_2.TextFrame.Text = "營銷部" & vbLf + "Sales Dept."
      node1_1_3.TextFrame.Text = "生產部" & vbLf + "Productive Dept."
      node1_1_4.TextFrame.Text = "財務部" & vbLf + "Finance Dept."
      node1_1_5.TextFrame.Text = "人力資源部" & vbLf + "HR Dept."
      node1_1_6.TextFrame.Text = "質檢中心" & vbLf + "Quality Center"
      node1_1_1_1.TextFrame.Text = "采購部" & vbLf + "Purchase Dept."
      node1_1_1_2.TextFrame.Text = "倉庫管理" & vbLf + "Warehouse Manager"
      node1_1_1_3.TextFrame.Text = "物流部" & vbLf + "Logistics Dept."
      node1_1_3_1.TextFrame.Text = "生產車間" & vbLf + "Production Dept."
      node1_1_3_2.TextFrame.Text = "維修部" & vbLf + "Maintenance Dept."
      node1_1_6_1.TextFrame.Text = "生產質量管理" & vbLf + "Production Quality Mgt."
      node1_1_6_2.TextFrame.Text = "生產安全管理" & vbLf + "Production Safety Mgt."
      node1_1_6_3.TextFrame.Text = "環境管理" & vbLf + "Environmental Mgt."


      '保存文檔
      ppt.SaveToFile("result.pptx", FileFormat.Pptx2013)
      System.Diagnostics.Process.Start("result.pptx")
    End Sub
  End Class
End Namespace

示例2. 編輯PPT SmartArt圖形

using Spire.Presentation;
using Spire.Presentation.Diagrams;


namespace ModifySmartArt
{
  class Program
  {
    static void Main(string[] args)
    {
      //加載PPT幻燈片文檔
      Presentation ppt = new Presentation();
      ppt.LoadFromFile("test.pptx");

      //獲取SmartArt圖形的節點集合
      ISmartArt smartart = ppt.Slides[0].Shapes[0] as ISmartArt;
      ISmartArtNodeCollection nodes = smartart.Nodes;

      //更改節點內容
      nodes[1].TextFrame.Text = "新修改的節點內容";

      //添加超鏈接到節點
      nodes[2].Click = new ClickHyperlink("https://baike.baidu.com/");//添加指向網頁的超鏈接
      nodes[3].Click = new ClickHyperlink(ppt.Slides[1]);//添加指向指定幻燈片的超鏈接

      //添加節點
      ISmartArtNode newnode = nodes[5].ChildNodes.AddNode();
      newnode.TextFrame.Text = "新添加的節點內容";

      //刪除節點
      //nodes[0].ChildNodes[3].ChildNodes.RemoveNodeByPosition(0); 

      //保存到本地并打開
      ppt.SaveToFile("output.pptx", FileFormat.Pptx2010);
      System.Diagnostics.Process.Start("output.pptx");
    }
  }
}

添加超鏈接后,注意要在幻燈片播放下才可見超鏈接添加效果:

使用C# / VB.NET 實現在PPT中創建、編輯PPT SmartArt圖形

VB.NET

Imports Spire.Presentation
Imports Spire.Presentation.Diagrams


Namespace ModifySmartArt
  Class Program
    Private Shared Sub Main(args As String())
      '加載PPT幻燈片文檔
      Dim ppt As New Presentation()
      ppt.LoadFromFile("test.pptx")

      '獲取SmartArt圖形的節點集合
      Dim smartart As ISmartArt = TryCast(ppt.Slides(0).Shapes(0), ISmartArt)
      Dim nodes As ISmartArtNodeCollection = smartart.Nodes

      '更改節點內容
      nodes(1).TextFrame.Text = "新修改的節點內容"

      '添加超鏈接到節點
      nodes(2).Click = New ClickHyperlink("https://baike.baidu.com/")
      '添加指向網頁的超鏈接
      nodes(3).Click = New ClickHyperlink(ppt.Slides(1))
      '添加指向指定幻燈片的超鏈接
      '添加節點
      Dim newnode As ISmartArtNode = nodes(5).ChildNodes.AddNode()
      newnode.TextFrame.Text = "新添加的節點內容"

      '刪除節點
      'nodes[0].ChildNodes[3].ChildNodes.RemoveNodeByPosition(0); 

      '保存到本地并打開
      ppt.SaveToFile("output.pptx", FileFormat.Pptx2010)
      System.Diagnostics.Process.Start("output.pptx")
    End Sub
  End Class
End Namespace

看完上述內容,你們對使用C# / VB.NET 實現在PPT中創建、編輯PPT SmartArt圖形有進一步的了解嗎?如果還想了解更多知識或者相關內容,請關注億速云行業資訊頻道,感謝大家的支持。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

大荔县| 磐石市| 永胜县| 区。| 张家口市| 玉门市| 临颍县| 繁昌县| 卢龙县| 建水县| 阿鲁科尔沁旗| 聂拉木县| 明星| 高州市| 涟水县| 高台县| 平和县| 资中县| 阳原县| 自贡市| 沙雅县| 宝山区| 安阳县| 格尔木市| 吴桥县| 平阳县| 鄂尔多斯市| 托里县| 连南| 彭州市| 广汉市| 临邑县| 庆云县| 汾西县| 交口县| 聂荣县| 嘉黎县| 临沂市| 新余市| 资讯| 丰城市|