国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

使用Aspose.Slides對PPT進行操作

這篇具有很好參考價值的文章主要介紹了使用Aspose.Slides對PPT進行操作。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

前言

開發(fā).NET項目常用的和office相關(guān)的庫有開源組件Apose.Slides和Spire.Presentation,以及微軟自帶的Microsoft.office.interop.PowerPoint組件。

微軟自帶的Microsoft.office.interop.PowerPoint組件雖然免費,但是需要在服務(wù)器端安裝PowerPoint,且需要配置DCOM組件權(quán)限,并且原生方法有限,導入附件、圖片等功能收到限制,經(jīng)過權(quán)衡,放棄使用微軟自帶的組件。

Apose.Slides和Spire.Presentation這兩個都是商業(yè)軟件,試用版和免費版的只有能生成前10頁,還帶有水印。Free Spire.Presentation可以沒有能超過十頁,否則需要購買商業(yè)付費版。

但是網(wǎng)上存在Apose.Slides的破解版本,可以完美解鎖大部分常用功能,最終采用Apose.Slides.net 17.9作為最終的開發(fā)組件,經(jīng)過測試滿足此次開發(fā)需求。

Aspose.Slides下載地址

https://download.csdn.net/download/weixin_35770067/86630578

開發(fā)環(huán)境
Visual Studio 2019

Microsoft Visual Studio是微軟公司的開發(fā)工具包系列產(chǎn)品。VS是一個基本完整的開發(fā)工具集,它包括了整個軟件生命周期中所需要的大部分工具,如UML工具、代碼管控工具、集成開發(fā)環(huán)境(IDE)等等。所寫的目標代碼適用于微軟支持的所有平臺。Visual Studio包含基于組件的開發(fā)工具(如Visual C#、Visual J#、Visual Basic和Visual C++),以及許多用于簡化基于小組的解決方案的設(shè)計、開發(fā)和部署的其他技術(shù)。

這里我們主要使用的是Visual Studio的Visual C#開發(fā)工具。

Microsoft開發(fā)組件

Apose.Slides.dll
開發(fā)過程中,需要引用上述類庫,用于創(chuàng)建、操作、保存PPT等操作。

官方文檔

https://docs.aspose.com/slides/net/open-presentation/文章來源地址http://www.zghlxwxcb.cn/news/detail-494093.html

Apose.Slides.dll 主要功能函數(shù)
創(chuàng)建PPT
// Instantiate a Presentation object that represents a presentation fileusing (Presentation presentation = new Presentation()){
    // Get the first slide    ISlide slide = presentation.Slides[0];
    // Add an autoshape of type line    slide.Shapes.AddAutoShape(ShapeType.Line, 50, 150, 300, 0);
    presentation.Save("NewPresentation_out.pptx", SaveFormat.Pptx);}
保存PPT
// Instantiate a Presentation object that represents a PPT file
Presentation presentation= new Presentation();
//...do some work here...// Save your presentation to a filepresentation.Save("Saved_out.pptx", 
Aspose.Slides.Export.SaveFormat.Pptx);
增加PPT
// Instantiate Presentation class that represents a presentation file
using (Presentation pres = new Presentation("CloneWithinSamePresentationToEnd.pptx")){
// Clone the desired slide to the end of the collection of slides in the same presentation    
ISlideCollection slds = pres.Slides;
slds.AddClone(pres.Slides[0]);
    // Write the modified presentation to disk    
    pres.Save("Aspose_CloneWithinSamePresentationToEnd_out.pptx", SaveFormat.Pptx);
}
刪除PPT
// Instantiate a Presentation object that represents a presentation file
using (Presentation pres = new Presentation("RemoveSlideUsingReference.pptx")){
// Accessing a slide using its index in the slides collection    
    ISlide slide = pres.Slides[0];
// Removing a slide using its reference    
    pres.Slides.Remove(slide);
//Writing the presentation file    
    pres.Save("modified_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
    }
修改PPT文本
using(Presentation pres = new Presentation("text.pptx")){
   foreach (ISlide slide in pres.Slides)
   {
       foreach (IShape shape in slide.Shapes)
       {
           if (shape is IAutoShape autoShape) //Checks if shape supports text frame (IAutoShape).            {
              foreach (IParagraph paragraph in autoShape.TextFrame.Paragraphs) //Iterates through paragraphs in text frame               {
                   foreach (IPortion portion in paragraph.Portions) //Iterates through each portion in paragraph                   {
                       portion.Text = portion.Text.Replace("years", "months"); //Changes text                       portion.PortionFormat.FontBold = NullableBool.True; //Changes formatting                   }
               }
           }
       }
   }
   //Saves the modified presentation   
   pres.Save("text-changed.pptx", SaveFormat.Pptx);}
增加圖片導入
using (Presentation pres = new Presentation()){
    ISlide slide = pres.Slides[0];
    IPPImage image = pres.Images.AddImage(File.ReadAllBytes("image.png"));
    slide.Shapes.AddPictureFrame(ShapeType.Rectangle, 10, 10, 100, 100, image);
    pres.Save("pres.pptx", SaveFormat.Pptx);}
增加視頻導入
// Instantiate Presentation class that represents the PPTX
using (Presentation pres = new Presentation()){
// Get the first slide    
ISlide sld = pres.Slides[0];
// Embedd vide inside presentation    
IVideo vid = pres.Videos.AddVideo(new FileStream("Wildlife.mp4", FileMode.Open));
// Add Video Frame    
IVideoFrame vf = sld.Shapes.AddVideoFrame(50, 150, 300, 350, vid);
// Set video to Video Frame    
vf.EmbeddedVideo = vid;
// Set Play Mode and Volume of the Video    
vf.PlayMode = VideoPlayModePreset.Auto;
    vf.Volume = AudioVolumeMode.Loud;
// Write the PPTX file to disk    
pres.Save("VideoFrame_out.pptx", SaveFormat.Pptx);}
增肌OLE文件導入
using (Presentation pres = new Presentation()){
  ISlide slide = pres.Slides[0];
  
  byte[] htmlBytes = File.ReadAllBytes("embedOle.html");
  IOleEmbeddedDataInfo dataInfoHtml = new OleEmbeddedDataInfo(htmlBytes, "html");
  IOleObjectFrame oleFrameHtml = slide.Shapes.AddOleObjectFrame(150, 120, 50, 50, dataInfoHtml);
  oleFrameHtml.IsObjectIcon = true;
  byte[] zipBytes = File.ReadAllBytes("embedOle.zip");
  IOleEmbeddedDataInfo dataInfoZip = new OleEmbeddedDataInfo(zipBytes, "zip");
  IOleObjectFrame oleFrameZip = slide.Shapes.AddOleObjectFrame(150, 220, 50, 50, dataInfoZip);
  oleFrameZip.IsObjectIcon = true;
  pres.Save("embeddedOle.pptx", SaveFormat.Pptx);}
增加文本框
// Instantiates PresentationExusing (Presentation pres = new Presentation()){
// Gets the first slide in the presentation    
ISlide sld = pres.Slides[0];
// Adds an AutoShape with type set as Rectangle    
IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 150, 50);
// Adds TextFrame to the Rectangle    
ashp.AddTextFrame(" ");
// Accesses the text frame    
ITextFrame txtFrame = ashp.TextFrame;
// Creates the Paragraph object for text frame    
IParagraph para = txtFrame.Paragraphs[0];
// Creates a Portion object for the paragraph    
IPortion portion = para.Portions[0];
// Sets the text    
portion.Text = "Aspose TextBox";
// Saves the presentation to disk   
 pres.Save("TextBox_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);}
參考文獻
  • https://docs.aspose.com/slides/net/create-presentation/

到了這里,關(guān)于使用Aspose.Slides對PPT進行操作的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • 【工具插件類教學】Unity通過Aspose讀取并顯示打開PDF,PPT,Excel,Word

    目錄 一、獲取Aspose支持.Net的DLL 二、導入Unity的Plugin文件夾 三、分別編寫四種文件的讀取顯示

    2024年02月02日
    瀏覽(98)
  • Office如何通過VSTO進行PPT插件開發(fā)?

    Office如何通過VSTO進行PPT插件開發(fā)?

    ??VSTO(Visual Studio Tools for Office )是VBA的替代,是一套用于創(chuàng)建自定義Office應(yīng)用程序的Visual Studio工具包。VSTO可以用Visual Basic 或者Visual C#擴展Office應(yīng)用程序(例如Word、Excel、PPT)。本文通過VSTO進行PPT插件開發(fā)總結(jié),并進行記錄。 ?? (1)安裝Visual Studio ??在百度等瀏覽器搜

    2024年02月17日
    瀏覽(31)
  • aspose-words、itextpdf完美解決java將word、excel、ppt、圖片轉(zhuǎn)換為pdf文件

    aspose-words、itextpdf完美解決java將word、excel、ppt、圖片轉(zhuǎn)換為pdf文件

    我是 傲驕鹿先生 ,沉淀、學習、分享、成長。 如果你覺得文章內(nèi)容還可以的話,希望不吝您的「一鍵三連」,文章里面有不足的地方希望各位在評論區(qū)補充疑惑、見解以及面試中遇到的奇葩問法 面對日常開發(fā)過程中,將各種文件轉(zhuǎn)換為pdf文件的問題,總是讓人頭疼,這次終

    2024年02月03日
    瀏覽(96)
  • 使用 GPT4 和 ChatGPT 開發(fā)應(yīng)用:前言到第三章

    使用 GPT4 和 ChatGPT 開發(fā)應(yīng)用:前言到第三章

    原文:Developing Apps with GPT-4 and ChatGPT 譯者:飛龍 協(xié)議:CC BY-NC-SA 4.0 在發(fā)布僅僅五天后,ChatGPT 就吸引了驚人的一百萬用戶,這在科技行業(yè)及其他領(lǐng)域引起了轟動。作為一個副作用,OpenAI API 用于人工智能文本生成的接口突然曝光,盡管它已經(jīng)可用了三年。ChatGPT 界面展示了這

    2024年01月20日
    瀏覽(29)
  • 使用Spring框架進行Web項目開發(fā)(初級)

    使用Spring框架進行Web項目開發(fā)(初級)

    目錄 前言 1. 為什么常規(guī)的Spring框架不適合Web項目呢? 2. 如何在Spring框架中創(chuàng)建容器? 3. Spring框架開發(fā)Web項目的步驟 3.1 創(chuàng)建maven項目 3.2 添加相應(yīng)的依賴 3.3 在webapp目錄下的web.xml中注冊監(jiān)聽器 3.4 在webapp文件夾下的web.xml中配置Servlet控制器 3.5 自定義控制器 ?總結(jié) 我們在初步

    2024年01月19日
    瀏覽(24)
  • 如何使用 Lightly 進行 Python GUI 項目開發(fā)

    如何使用 Lightly 進行 Python GUI 項目開發(fā)

    GUI 即圖形用戶界面(Graphical User Interface)的縮寫,是一種使用圖形交互的界面系統(tǒng)。這種系統(tǒng)為軟件提供圖標、菜單等視覺交互性強的部件,讓用戶能通過點擊、拖動、下拉等方式操作電腦中的軟件和應(yīng)用程序。GUI 所展示的物體可以傳遞各式各樣的信息,同時也會隨著用戶

    2024年02月05日
    瀏覽(19)
  • Qt項目開發(fā)經(jīng)驗:在Linux平臺下使用Qt進行開發(fā)

    Qt項目開發(fā)經(jīng)驗:在Linux平臺下使用Qt進行開發(fā) 如今,Qt已成為跨平臺應(yīng)用程序開發(fā)中的一大寵兒。在Linux平臺下,Qt的應(yīng)用也是越來越廣泛了。今天,我將和大家分享一些我在Linux平臺下使用Qt進行開發(fā)的經(jīng)驗。 首先,在Linux平臺下安裝Qt并不復雜。我們可以通過apt-get工具來安

    2024年02月08日
    瀏覽(27)
  • 【微信小程序】使用vscode進行小程序項目的開發(fā)

    【微信小程序】使用vscode進行小程序項目的開發(fā)

    如果我們不想寫wxss,想寫less、scss,但是less、scss以前都是編譯成css的,這時候我們可以進行在vscode環(huán)境配置的設(shè)置 下載插件 想利用本身已經(jīng)熟悉的prettier功能、vscode環(huán)境配置的設(shè)置? 雖然可以利用vscode進行小程序代碼的開發(fā),但是“微信開發(fā)者工具”是脫離不了的,因為需

    2024年02月05日
    瀏覽(24)
  • 基礎(chǔ)前端使用web3 進行區(qū)塊鏈項目開發(fā)

    這篇文章不會些區(qū)塊鏈的機制算法等一切,只是對前端開發(fā)者,如何快速上手進行區(qū)塊鏈項目開發(fā)做一個簡單的引導。 閱讀本文之前,需要了解一些簡單的區(qū)塊鏈知識,能回答以下四個問題就可以閱讀本文了。 1、區(qū)塊鏈是什么? 2、區(qū)塊鏈節(jié)點是什么? 3、錢包是什么? 4、

    2024年02月01日
    瀏覽(21)
  • UniApp項目中 使用微信小程序原生語言 進行開發(fā)

    UniApp項目中 使用微信小程序原生語言 進行開發(fā)

    wxcomponents 下放的是微信小程序原生代碼寫的組件。我進行了封裝 在你下uniApp 項目的根目錄創(chuàng)建一個 wxcomponents 名字千萬不要錯 京東、支付寶燈參考下面圖片 官方文檔也有介紹 然后在你需要引入原生功能的頁面里面引入你的組件(我這里提前已經(jīng)放過來了。在上面圖可看到

    2024年02月04日
    瀏覽(100)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包