user198003
user198003

Reputation: 11151

Programmatically create MS Word file without having MS Word installed

How can I create Word files in C# using Visual Studio 2008, without Word on my PC?

Do I need to have Word installed on my PC, to be able to create Word files using Visual Studio 2008?

Thanks in advance!

Upvotes: 5

Views: 2583

Answers (3)

JasonPlutext
JasonPlutext

Reputation: 15863

Use the Open XML SDK.

You don't need Word installed.

A nice feature of Visual Studio is that you can drag/drop a docx onto it, and explore its structure and see its XML.

Upvotes: 2

Joey
Joey

Reputation: 354356

You can use the Open XML Format SDK:

The 2007 Microsoft® Office system introduces a new file format that is based on XML called Open XML Formats. Microsoft Office Word 2007, Microsoft Office Excel® 2007, and Microsoft Office PowerPoint® 2007 all use these formats as the default file format.

Open XML formats are useful for developers because they are an open standard and are based on well-known technologies: ZIP and XML. Microsoft provides a library for accessing these files as part of the WinFX technologies in the System.IO.Packaging namespace.

The Open XML Format SDK is built on top of the System.IO.Packaging API and provides strongly typed part classes to manipulate Open XML documents.

Upvotes: 9

VVS
VVS

Reputation: 19604

That depends on the version of the Word file. Starting with Word 2007 Microsoft implemented the .docx-Format which is essentially an XML file inside a ZIP-archive. The format of the XML file is well documented and I believe there are lots of projects out there that are capable of creating those files.

Alternatively take a look at the Open Document Format. It's "more open" and Word 2007+ is capable of opening files created with it.

Upvotes: 2

Related Questions