รหัส C # การแปลงสไลด์ PowerPoint กับภาพ

การตีพิมพ์: 2012-02-23

หากคุณต้องการที่จะทำให้กระบวนการทางธุรกิจและการส่งออกไฟล์ PowerPoint ของคุณเพื่อภาพแล้วรหัสนี้จะมีประโยชน์จริงๆ นี้รหัส C # จะช่วยให้คุณสามารถเปิดไฟล์ PowerPoint โปรแกรมแล้วส่งออกภาพนิ่งกับภาพ

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Office.Core; using Microsoft.Office.Interop.PowerPoint; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Application pptApplication = new Application(); Presentation pptPresentation = pptApplication.Presentations .Open("test.pptx", MsoTriState.msoFalse,MsoTriState.msoFalse , MsoTriState.msoFalse); pptPresentation.Slides[1].Export("slide.png", "png", 320, 240); } } } 

ในตัวอย่างที่เราจะเห็นได้ว่าครั้งแรกที่เรากำลังเปิด PPT หรือแฟ้ม .pptx กับโปรแกรมประยุกต์วัตถุและจากนั้นเลือกภาพนิ่งแรกใช้อาร์เรย์สไลด์ ในที่สุดเราจะใช้ฟังก์ชั่นการส่งออกการส่งออกเลื่อนไปยังรูปแบบ PNG คุณสามารถเปลี่ยนรูปแบบออกเป็น JPG แต่คุณอาจสูญเสียคุณภาพบางอย่างในภาพออก