提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
原创|使用教程|编辑:李显亮|2020-11-24 10:44:09.870|阅读 637 次
概述:Spire系列文档处理API是国产开发工具中功能可媲美Aspose的强大控件,帮助开发者轻松将文档功能集成到应用程序中。临近年终,小编为您倾情献上Spire.Doc在各类开发语言中格式转换的示例教程,记得收藏哦!
#慧都22周年庆大促·界面/图表报表/文档/IDE/IOT/测试等千款热门软控件火热促销中>>
将文档从一种格式转换为另一种格式是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@hmdbvip.cn




在现代软件开发过程中,自动化单元测试是确保代码质量与可靠性的关键环节。尤其对于特定框架(如MFC)的代码,测试复杂度显著增加,常因依赖外部资源或交互操作而难以在静默环境中顺利执行。Parasoft C/C++test作为专业的软件测试工具,致力于帮助开发团队高效实施自动化测试,通过其强大的桩函数功能,能够有效模拟依赖组件的行为,从而实现对复杂逻辑的隔离测试。
本文将为大家介绍如何在MyEclipse中使用XDoclet开发EJB 2 Session Bean,欢迎下载最新版体验!
如果能将 CSV 自动转换为 PDF ,就能快速生成清晰、美观的报表,既节省手动排版时间,又能保持数据的专业呈现。本文将介绍如何使用 Spire.XLS for Java 实现这一过程——从加载 CSV 到输出高质量 PDF,仅需数行代码即可完成。
Parasoft C/C++test是一款专为C/C++代码设计的自动化测试工具,通过静态代码分析、单元测试和运行时错误检测等功能,帮助开发团队在早期发现并修复缺陷,提升代码质量和开发效率 。在实际使用中,尤其是在VC6此类旧版开发环境中执行单元测试时,可能会因环境兼容性问题触发链接错误。
相关产品
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@hmdbvip.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
永利最大(官方)网站