翻譯|使用教程|編輯:李顯亮|2020-10-27 10:49:58.320|閱讀 939 次
概述:Microsoft Word文檔主要有兩種類(lèi)型,DOC和DOCX??梢允褂肅#或VB.NET以編程方式將DOCX轉(zhuǎn)換為DOC,也可以將DOCX轉(zhuǎn)換為DOCX。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
相關(guān)鏈接:
Aspose.Words for .NET是高級(jí)Word文檔處理API,用于執(zhí)行各種文檔管理和操作任務(wù)。該API支持生成,修改,轉(zhuǎn)換,呈現(xiàn)和打印文檔的能力,而無(wú)需在跨平臺(tái)應(yīng)用程序中直接利用Microsoft Word。
Microsoft Word文檔主要有兩種類(lèi)型,DOC和DOCX??梢允褂肅#或VB.NET以編程方式將DOCX轉(zhuǎn)換為DOC,也可以將DOCX轉(zhuǎn)換為DOCX??梢灾饌€(gè)處理和轉(zhuǎn)換每個(gè)文檔,或者,如果需要處理大量文件,可以批量轉(zhuǎn)換DOC和DOCX文件。讓我們探索以下用例以詳細(xì)了解該主題:
>>Aspose.Words for .NET已經(jīng)更新至v20.10,此常規(guī)的每月版本中有89項(xiàng)改進(jìn)和修復(fù),包括添加了對(duì)加載CHM文檔的支持等新功能,歡迎下載體驗(yàn)。(安裝包僅提供部分功能,并設(shè)置限制,如需試用完整功能請(qǐng)。)
點(diǎn)擊下載最新版Aspose.Words for .NET
DOC和DOCX之間的主要區(qū)別在于DOC文件格式是二進(jìn)制文件,其中DOCX文件格式是包含所有相關(guān)XML文件的ZIP文件。您可以按照以下步驟將DOCX文件轉(zhuǎn)換為DOC文檔:
下面的代碼段顯示了如何使用C?;騐B.NET將DOCX轉(zhuǎn)換為DOC:
// Specify LoadFormat of input word document Aspose.Words.LoadOptions options = new Aspose.Words.LoadOptions(); options.LoadFormat = Aspose.Words.LoadFormat.Docx ; // Load source DOCX file Aspose.Words.Document document = new Aspose.Words.Document(dataDir + "file.doc", options); // Convert DOCX to DOC file document.Save(dataDir + "test.doc", Aspose.Words.SaveFormat.Docx);
可能需要在.NET應(yīng)用程序中將數(shù)百個(gè)DOCX文件轉(zhuǎn)換為DOC格式。您只需執(zhí)行一次程序即可輕松轉(zhuǎn)換一批文件。請(qǐng)按照以下步驟轉(zhuǎn)換一批DOCX文件:
以下代碼顯示了如何使用C?;騐B.NET將一批DOCX文件轉(zhuǎn)換為DOC格式文件:
string[] files = Directory.GetFiles(dataDir, "*.docx"); foreach (var file in files) { // Specify LoadFormat of input word document Aspose.Words.LoadOptions options = new Aspose.Words.LoadOptions(); options.LoadFormat = Aspose.Words.LoadFormat.Docx; // Load source DOCX file Aspose.Words.Document document = new Aspose.Words.Document(file, options); var filename = Path.ChangeExtension(file, ".doc"); // Convert DOCX to DOC file document.Save(filename, Aspose.Words.SaveFormat.Doc); }
可以使用C?;騐B.NET在基于.NET Framework的應(yīng)用程序中將Microsoft Word DOC文件轉(zhuǎn)換為DOCX格式文件。以下是執(zhí)行轉(zhuǎn)換的步驟:
下面的代碼顯示了如何使用C?;騐B.NET將DOC轉(zhuǎn)換為DOCX:
// Specify LoadFormat of input word document Aspose.Words.LoadOptions options = new Aspose.Words.LoadOptions(); options.LoadFormat = Aspose.Words.LoadFormat.Doc; // Load source DOC file Aspose.Words.Document document = new Aspose.Words.Document(dataDir + "test.doc" , options); // Convert DOC to DOCX file document.Save(dataDir + "test.docx" , Aspose.Words.SaveFormat.Docx);
可以處理將多個(gè)文件和不同批次轉(zhuǎn)換為DOC到DOCX的轉(zhuǎn)換。您需要按照以下步驟轉(zhuǎn)換此類(lèi)文件:
下面的代碼示例說(shuō)明了如何使用C?;騐B.NET將一批DOC文件轉(zhuǎn)換為DOCX文件:
string[] files = Directory.GetFiles(dataDir, "*.doc"); foreach (var file in files) { // Specify LoadFormat of input word document Aspose.Words.LoadOptions options = new Aspose.Words.LoadOptions(); options.LoadFormat = Aspose.Words.LoadFormat.Doc; // Load source DOC file Aspose.Words.Document document = new Aspose.Words.Document(file, options); var filename = Path.ChangeExtension(file, ".docx"); // Convert DOC to DOCX file document.Save(filename, Aspose.Words.SaveFormat.Docx); }
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn