没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
原创|使用教程|编辑:李显亮|2020-11-24 10:44:09.870|阅读 629 次
概述:Spire系列文档处理API是国产开发工具中功能可媲美Aspose的强大控件,帮助开发者轻松将文档功能集成到应用程序中。临近年终,小编为您倾情献上Spire.Doc在各类开发语言中格式转换的示例教程,记得收藏哦!
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
将文档从一种格式转换为另一种格式是Spire.Doc的主要功能之一。这种转换只不过是加载和保存操作的组合。因此,使用Spire.Doc可以将文档从任何受支持的加载格式转换为任何受支持的保存格式。
本文整理了包括在C#中以下文件格式的转换指南,希望对您有所帮助:
>>你可以点击这里下载Spire.Doc for .NET测试体验。
(篇幅较长,建议收藏阅读)
using System;
using System.Windows.Forms;
using Spire.Doc;
using Spire.Doc.Documents;
namespace to XML
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//Create word document
Document document = new Document();
document.LoadFromFile(@"D:\Sample.doc");
//Save doc file.
document.SaveToFile("Sample.xml", FileFormat.Xml);
//Launching the MS Word file.
WordDocViewer("Sample.xml");
}
private void WordDocViewer(string fileName)
{
try
{
System.Diagnostics.Process.Start(fileName);
}
catch { }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Doc;
namespace Xml2Word
{
class Program
{
static void Main(string[] args)
{
Document doc = new Document();
doc.LoadFromFile("sample.xml", FileFormat.Xml);
doc.SaveToFile("test.doc", FileFormat.Doc);
}
}
}
using Spire.Doc;
namespace XML2PDf
{
class Program
{
static void Main(string[] args)
{
Document mydoc = new Document();
mydoc.LoadFromFile(@"..\sample.xml", FileFormat.Xml);
mydoc.SaveToFile("Test.doc", FileFormat.Doc);
mydoc.SaveToFile("test.pdf", FileFormat.PDF);
System.Diagnostics.Process.Start("Test.pdf");
}
}
}
using System;
using Spire.Doc;
using Spire.Doc.Documents;
namespace DoctoPDF
{
class toPDF
{
static void Main(string[] args)
{
//Load Document
Document document = new Document();
document.LoadFromFile(@"E:\work\documents\TestSample.docx");
//Convert Word to PDF
document.SaveToFile("toPDF.PDF", FileFormat.PDF);
//Launch Document
System.Diagnostics.Process.Start("toPDF.PDF");
}
}
}
using System;
using System.Windows.Forms;
using Spire.Doc;
using Spire.Doc.Documents;
namespace tohtml_3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//Create word document
Document document = new Document();
document.LoadFromFile(@"D:\Work\Stephen\2011.12.05\Sample.doc");
//Save doc file.
document.SaveToFile("Sample.txt", FileFormat.Txt);
//Launching the MS Word file.
WordDocViewer("Sample.txt");
}
private void WordDocViewer(string fileName)
{
try
{
System.Diagnostics.Process.Start(fileName);
}
catch { }
}
}
}
using Spire.Doc;
using Spire.Doc.Documents;
namespace Word_to_HTML
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//Create word document
Document document = new Document();
document.LoadFromFile(@"..\wordtohtml.doc");
//Save doc file to html
document.SaveToFile("toHTML.html", FileFormat.Html);
WordDocViewer("toHTML.html");
}
private void WordDocViewer(string fileName)
{
try
{
System.Diagnostics.Process.Start(fileName);
}
catch { }
}
}
}
using System;
using Spire.Doc;
using Spire.Doc.Documents;
namespace Html2Doc
{
class Program
{
static void Main(string[] args)
{
Document document = new Document();
document.LoadFromFile(@"D:\test.html",FileFormat.Html,XHTMLValidationType.None);
document.SaveToFile("test.doc", FileFormat.Doc);
}
}
}
using Spire.Doc;
using System;
namespace DOCRTF
{
class Program
{
static void Main(string[] args) { }
private void button1_Click(object sender, EventArgs e)
{
//Create word document
Document document = new Document();
document.LoadFromFile(@"D:\Sample.doc");
//Save doc file.
document.SaveToFile("Sample.rtf", FileFormat.Rtf);
//Launching the MS Word file.
WordDocViewer("Sample.rtf");
}
private void WordDocViewer(string fileName)
{
try
{
System.Diagnostics.Process.Start(fileName);
}
catch { }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using Spire.Doc;
using Spire.Doc.Documents;
namespace HTML2Image
{
class Program
{
static void Main(string[] args)
{
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Spire.Doc;
namespace Doc_to_xps
{
class Program
{
static void Main(string[] args)
{
//doc file
String file = "doc to xpsdoc.docx";
//open doc document
Document doc = new Document(file);
//convert to xps file.
doc.SaveToFile("doc to xpsSample.xps", FileFormat.XPS);
System.Diagnostics.Process.Start("doc to xpsSample.xps");
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
namespace HTML2PDFXPS
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Document document = new Document();
document.LoadFromFile("Good.htm", FileFormat.Html, XHTMLValidationType.None);
//Save html to PDF.
document.SaveToFile("Sample.pdf", FileFormat.PDF);
}
private void button2_Click(object sender, EventArgs e)
{
Document document = new Document();
document.LoadFromFile("Good.htm", FileFormat.Html, XHTMLValidationType.None);
//Save html to PDF.
document.SaveToFile("Sample.xps", FileFormat.XPS);
}
}
}
using Spire.Doc;
namespace wordconversion.Case
{
class WordtoSVG
{
public WordtoSVG()
{
Document doc = new Document();
doc.LoadFromFile("Sample.docx");
doc.SaveToFile("result.svg", FileFormat.SVG);
}
}
}
如果您有任何疑问或需求,请随时,我们很高兴为您提供查询和咨询。 本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@ke049m.cn




大型SaaS系统的自动化测试常常受制于界面变化快、结构复杂、加载机制多变等因素。从元素识别到脚本管理,SmartBear TestComplete帮助Salesforce建了可靠的自动化测试体系。
BarTender 标签管理系统,正是帮助企业轻松实现 GS1 标准化标签设计、编码生成与信息联动的强大工具。
Parasoft C/C++test 是一款功能强大的 C/C++ 软件测试工具,集成了静态代码分析、单元测试、集成测试和覆盖率分析等功能,单元测试作为其关键功能之一,为了适配多样化的目标部署环境,C/C++test 设计了灵活的测试结果收集机制。通过Socket通讯方式来收集单元测试结果,从而扩展其测试覆盖范围与应用场景。
Parasoft C/C++test作为一款功能全面的自动化代码质量保障工具,为C/C++开发者提供了静态分析、单元测试和运行时错误检测等核心功能。通过将其与轻量级且广受欢迎的VScode编辑器集成,开发团队可以在熟悉的编码环境中实时获得代码质量反馈,有效提升开发效率与代码可靠性。
相关产品
Spire.Doc for .NET 是一款专门对 Word 文档进行操作的 .NET 类库。
Spire.Office for .NET专业的.NET Office套件,涵盖office文档创建、编辑、转换、管理和OCR内容识别等操作
最新文章 MORE
半岛外围网上直营相关的文章 MORE
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@ke049m.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
半岛外围网上直营