69pao国产精品视频-久久精品一区二区二三区-精品国产精品亚洲一本大道-99国产综合一区久久

利用C#/VB.NET實現(xiàn)PPT轉(zhuǎn)換為HTML

利用c#/vb.net實現(xiàn)ppt轉(zhuǎn)換為html

利用powerpoint可以很方便的呈現(xiàn)多媒體信息,且信息形式多媒體化,表現(xiàn)力強。但難免在某些情況下我們會需要將powerpoint轉(zhuǎn)換為html格式。因為html文檔能獨立于各種操作系統(tǒng)平臺(如unix,windows等)。并且它可以加入圖片、聲音、動畫、影視等內(nèi)容,還能從一個文件跳轉(zhuǎn)到另一個文件,與世界各地主機的文件連接。通過html可以表現(xiàn)出豐富多彩的設(shè)計風格,實現(xiàn)頁面之間的跳轉(zhuǎn),展現(xiàn)多媒體的效果。本文就將詳細介紹如何通過c#/vb.net代碼將powerpoint轉(zhuǎn)換為html。

  • 將powerpoint演示文稿轉(zhuǎn)換為html
  • 將特定的powerpoint幻燈片轉(zhuǎn)換為html

 

程序環(huán)境

本次測試時,在程序中引入free spire.presentation for .net。可通過以下方法引用 free spire.presentation.dll文件:

方法1:將free spire.presentation for .net下載到本地,解壓,安裝。安裝完成后,找到安裝路徑下bin文件夾中的 spire.presentation.dll。然后在visual studio中打開“解決方案資源管理器”,鼠標右鍵點擊“引用”,“添加引用”,將本地路徑bin文件夾下的dll文件添加引用至程序。

方法2:通過nuget安裝。可通過以下2種方法安裝:

(1)可以在visual studio中打開“解決方案資源管理器”,鼠標右鍵點擊“引用”,“管理nuget包”,然后搜索“free spire.presentation”,點擊“安裝”。等待程序安裝完成。

(2)將以下內(nèi)容復(fù)制到pm控制臺安裝。

install-package freespire.presentation -version 7.8.0

 

將powerpoint演示文稿轉(zhuǎn)換為html

presentation.savetofile(string, fileformat)方法用于將powerpoint演示文稿轉(zhuǎn)換為其他文件格式,如pdf、xps和html。在以下步驟中,我們將向您展示如何使用free spire.presentation for .net將powerpoint演示文稿轉(zhuǎn)換為html:

  • 初始化presentation類的實例。
  • 使用presentation.loadfromfile(string)方法加載powerpoint演示文稿。
  • 使用presentation.savetofile(string, fileformat)方法將powerpoint演示文稿保存為html格式。

完整代碼

c#

using spire.presentation;
using system;
namespace convertpowerpointtohtml
{
  class program
  {
      static void main(string[] args)
      {
          //初始化presentation類的實例
          presentation ppt = new presentation();
          //加載powerpoint演示文稿
          ppt.loadfromfile("柯基.pptx");
          //指定輸出html文件的文件路徑
          string result = " d:\\.net\\powerpoint\\powerpointtohtml.html";
          //將powerpoint演示文稿保存為html格式
          ppt.savetofile(result, fileformat.html);
      }
  }
}

vb.net

imports spire.presentation

namespace convertpowerpointtohtml
  friend class program
      private shared sub main(byval args as string())
          '初始化presentation類的實例
          dim ppt as presentation = new presentation()
          '加載powerpoint演示文稿
          ppt.loadfromfile("柯基.pptx")

          '指定輸出html文件的文件路徑
          dim result = " d:\\.net\\powerpoint\\powerpointtohtml.html"

          '將powerpoint演示文稿保存為html格式
          ppt.savetofile(result, fileformat.html)
      end sub
  end class
end namespace

效果圖

 

將特定的powerpoint幻燈片轉(zhuǎn)換為html

在某些情況下,您可能需要將特定的幻燈片而不是整個演示文稿轉(zhuǎn)換為html。islide.savetofile(string, fileformat)方法可以將powerpoint幻燈片轉(zhuǎn)換為html。具體步驟如下:

  • 初始化presentation類的實例。
  • 使用presentation.loadfromfile()方法加載powerpoint演示文稿。
  • 通過presentation.slides[int]屬性按索引獲取powerpoint演示文稿中的特定幻燈片。
  • 使用islide.savetofile(string, fileformat)方法將powerpoint幻燈片保存為html格式。

完整代碼

c#

using spire.presentation;
using system;

namespace convertpowerpointslidetohtml
{
  class program
  {
      static void main(string[] args)
      {
          //初始化presentation類的實例
          presentation presentation = new presentation();
          //加載powerpoint演示文稿
          presentation.loadfromfile("柯基.pptx");

          //獲取特定幻燈片
          islide slide = presentation.slides[5];

          //指定輸出html文件的文件路徑
          string result = " d:\\.net\\powerpoint\\slidetohtml.html ";

          //將第一張幻燈片保存為html格式
          slide.savetofile(result, fileformat.html);
      }
  }
}

vb.net

imports spire.presentation

namespace convertpowerpointslidetohtml
  friend class program
      private shared sub main(byval args as string())
          '初始化presentation類的實例
          dim presentation as presentation = new presentation()
          '加載powerpoint演示文稿
          presentation.loadfromfile("柯基.pptx")

          '獲取特定幻燈片
          dim slide as islide = presentation.slides(5)

          '指定輸出html文件的文件路徑
          dim result = " d:\.net\powerpoint\slidetohtml.html "

          '將第一張幻燈片保存為html格式
          slide.savetofile(result, fileformat.html)
      end sub
  end class
end namespace

效果圖

關(guān)于利用c#/vb.net實現(xiàn)ppt轉(zhuǎn)換為html的文章就介紹至此,更多相關(guān)c# ppt轉(zhuǎn)html內(nèi)容請搜索碩編程以前的文章,希望以后支持碩編程!

下一節(jié):unityshader片段著色器使用基礎(chǔ)詳解

c# 教程

相關(guān)文章