將 ODT 轉(zhuǎn)換為 DOC
具有 .ODT 文件擴(kuò)展名的文件是 OpenDocument 文本文檔文件。這些文件通常由免費(fèi)的 OpenOffice Writer 文字處理器程序創(chuàng)建。ODT 文件類似于與 Microsoft Word 一起使用的流行 DOCX 文件格式。這兩種文件類型都可以保存文本、圖像、對(duì)象和樣式等內(nèi)容。
但是,當(dāng)您在 Microsoft Word 中打開(kāi) ODT 文檔時(shí),由于兩個(gè)程序不共享相同的功能,ODT 文檔的格式可能會(huì)有所不同。將 ODT 轉(zhuǎn)換為 DOCX 或反之時(shí),數(shù)據(jù)和內(nèi)容將成功轉(zhuǎn)換,但可能不包括原始格式。
以下代碼片段介紹了如何使用Spire.Doc for .NET 將 ODT 轉(zhuǎn)換為 DOC 或 DOCX,反之亦然。
(一) ODT 轉(zhuǎn) DOCX
要將 ODT 轉(zhuǎn)換為 DOC,請(qǐng)?jiān)?SaveToFile 方法中將文件擴(kuò)展名和文件格式更改為 .Doc。
[C#]
using Spire.Doc; namespace ODTtoDOCX { class Program { static void Main(string[] args) { Document doc = new Document(); doc.LoadFromFile("SampleODTFile.odt"); doc.SaveToFile("output.docx", FileFormat.Docx) } } }
[VB.NET]
Imports Spire.Doc Namespace ODTtoDOCX Class Program Private Shared Sub Main(args As String()) Dim doc As New Document() doc.LoadFromFile("SampleODTFile.odt") doc.SaveToFile("output.docx", FileFormat.Docx) End Sub End Class End Namespace
(二) DOCX 轉(zhuǎn) ODT
要將 Doc 轉(zhuǎn)換為 ODT,請(qǐng)?jiān)诩虞d源文件時(shí)加載 .Doc 文件格式的文檔。
[C#]
using Spire.Doc; namespace DOCXtoODT { class Program { static void Main(string[] args) { Document doc = new Document(); doc.LoadFromFile("SampleODTFile.odt"); doc.SaveToFile("output.docx", FileFormat.Docx); } } }
[VB.NET]
Imports Spire.Doc Namespace DOCXtoODT Class Program Private Shared Sub Main(args As String()) Dim doc As New Document() doc.LoadFromFile("SampleODTFile.odt") doc.SaveToFile("output.docx", FileFormat.Docx) End Sub End Class End Namespace
歡迎下載|體驗(yàn)更多E-iceblue產(chǎn)品
如需獲取更多產(chǎn)品相關(guān)信息請(qǐng)咨詢