翻譯|行業資訊|編輯:吉煒煒|2025-08-29 09:42:13.420|閱讀 56 次
概述:在本教程中,我們將探討如何開發一個以編程方式將 PowerPoint 轉換為 XML 的工具。Aspose.Slides for .NET允許您使用 C# 中的幾個類方法將 PPTX 轉換為 XML。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
	 
 
PowerPoint演示文稿用途廣泛。為了將這些演示文稿集成到自動化系統中進行分析和處理,您需要將這些 PPTX/PPT 文件轉換為機器可讀的格式。然而,XML是一種結構更清晰、更易于人類閱讀的格式。在本指南中,我們將探討如何開發一個以編程方式將 PowerPoint 轉換為 XML 的工具。Aspose.Slides for .NET允許您使用 C# 中的幾個類方法將 PPTX 轉換為 XML。
加入Aspose技術交流QQ群(1041253375),與更多小伙伴一起探討提升開發技能。
另一種方法是打開程序包管理器控制臺并運行以下命令:
Install-Package Aspose.Slides.NET
或者,通過 NuGet 包管理器安裝。
本節將介紹如何使用Aspose.Slides for .NET開發 PPT 到 XML 轉換器。
步驟:
要在 C# 中將 PPTX 轉換為 XML,請遵循下面給出的源代碼:
using Aspose.Slides;
using Aspose.Slides.Export;
namespace AsposeSlides
{
    class Graphics
    {
        static void Main(string[] args)
        {
            string outFilePath = "document.xml";
            string licensePath = "License.lic";
            // Apply license
            License lic = new License();
            lic.SetLicense(licensePath);
            // Create a new presentation by instantiating an instance of the Presentation class.
            using (Presentation pres = new Presentation())
            {
                // Access the first slide.
                ISlide slide = pres.Slides[0];
                // Call the AddAutoShape method to create a new auto shape with default formatting. 
                IAutoShape titleShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 50, 600, 50);
                // Add a title.
                titleShape.AddTextFrame("Hello Aspose.Slides!");
                // Set the font size.
                titleShape.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 24;
                // Add a content textbox and insert a title. 
                IAutoShape contentShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 120, 600, 300);
                contentShape.AddTextFrame("This is a sample slide with text added programmatically.");
                contentShape.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 16;
                // Save presentation as XML file by calling the Save method. 
                pres.Save(outFilePath, SaveFormat.Xml);
            }
        }
    }
}
上述代碼示例生成以下輸出: 
					
						
					
						 
 
					
							
借助Aspose.Silides 我們實現了如何在 C# 中將 PPTX 轉換為 XML。它可以輕松地將您的商業或教育演示文稿與基于 AI 的系統集成和處理。此外,通過將 PowerPoint 轉換為 XML,您的數據將變得更加靈活且可重復使用。
————————————————————————————————————————
關于慧都科技:
慧都科技是專注軟件工程、智能制造、石油工程三大行業的數字化解決方案服務商。在軟件工程領域,我們提供開發控件、研發管理、代碼開發、部署運維等軟件開發全鏈路所需的產品,提供正版授權采購、技術選型、個性化維保等服務,幫助客戶實現技術合規、降本增效與風險可控。慧都科技Aspose在中國的官方授權代理商,提供Aspose系列產品免費試用,咨詢,正版銷售等于一體的專業化服務。Aspose是文檔處理領域的優秀產品,幫助企業高效構建文檔處理的應用程序。
下載|體驗更多Aspose產品,請咨詢,或撥打產品熱線:023-68661681
加入Aspose技術交流QQ群(1041253375),與更多小伙伴一起探討提升開發技能。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@ke049m.cn
文章轉載自:慧都網