讀取 DOCX 文檔的任務就是讀取 DOM 模型中的分層數據結構的任務。這意味著了解每個單獨的 DOCX 數據元素的格式,包括其所有可能的子元素和屬性。
我們的 C# 庫是一個基於雲的解決方案,可讓您輕鬆打開 DOCX 文件進行讀寫。這種分佈式方法使您可以靈活地使用 C# 語言進行軟件開發,因為所有資源密集型 DOCX 文檔處理都將在 Aspose 服務器上進行。您只需要獲取私鑰即可在 C# 代碼中訪問 Cloud API。
您可以遍歷 DOCX 文檔的所有元素,也可以在 DOM 樹中搜索特定元素。我們提供了廣泛的 C# 函數,用於處理 DOCX 文件的結構和文檔節點中包含的數據。
以下代碼示例將幫助您快速了解如何使用 C# 加載 DOCX 文件並對其執行一些操作。
using Aspose.Words.Cloud.Sdk;
var config = new Configuration { ClientId = "####-####-####-####-####",
ClientSecret = "##################" };
var wordsApi = new WordsApi(config);
var fileName = "Input.docx";
using var requestFileContent = File.OpenRead(File.ReadAllText(fileName));
var uploadDocumentRequest = new UploadFileRequest(requestFileContent, fileName);
await wordsApi.UploadFile(uploadDocumentRequest);
var requestParagraph = new ParagraphInsert()
{
Text = "Reading and writing to the file in the cloud occurs automatically."
};
var insertParagraphRequest = new InsertParagraphRequest(fileName, requestParagraph);
await wordsApi.InsertParagraph(insertParagraphRequest);
var downloadDocumentRequest = new DownloadFileRequest(fileName);
await wordsApi.DownloadFile(downloadDocumentRequest);
使用 NuGet 包管理器安裝 'Aspose.Words Cloud SDK for .NET' 。只需運行 nuget install Aspose.Words-Cloud 即可在您的項目中自動安裝和引用相應的程序集。作為替代方案,您可以從 GitHub 手動克隆 Aspose.Words Cloud SDK for .NET 源代碼並在您的項目中使用它。請按照這些 Instructions 快速獲取必要的安全憑證並訪問我們的 REST API。