C# 将Word转为ODT、ODT转为Word

 时间:2026-02-12 22:58:54

1、在VS程序中打开“解决方案资源管理器”,鼠标右键点击“引用”,“管理NuGet包”:

C# 将Word转为ODT、ODT转为Word

2、点击“搜索”,在搜索框中输入搜索内容,点击包,安装:

C# 将Word转为ODT、ODT转为Word

3、依次点击“OK”,"我接受",等待程序安装。

C# 将Word转为ODT、ODT转为Word

4、完成安装后,编辑如下代码,实现格式转换:

1. Word转ODT

using Spire.Doc;

namespace WordtoODT

{

    class Program

    {

        static void Main(string[] args)

        {

            //创建Document类的对象

            Document document = new Document();

            //加载Word文档

            document.LoadFromFile("sample.docx");

            //保存为ODT格式

            document.SaveToFile("ToODT.odt", FileFormat.Odt);

        }

    }

}

2. ODT转Word

using Spire.Doc;

namespace ODTtoWord

{

    class Program

    {

        static void Main(string[] args)

        {

            //创建Document类的对象

            Document document = new Document();

            //加载ODT文档

            document.LoadFromFile("test.odt");

            //保存为Word格式

            document.SaveToFile("toWord.docx", FileFormat.Docx2013);

        }

    }

}

  • Acrobat Pro DC基本使用方法
  • 如何提高库房利用率
  • 怎么在word中打开软件
  • Word如何打印指定页面?
  • WPS中插入对象
  • 热门搜索
    十一月开什么花 什么是空巢老人 红霉素软膏的作用及功能 水果知识 百合的作用 男生生日送什么礼物好 苹果有什么好处 山药豆的功效与作用 教师的作用 比喻句的作用