Gios WORD .NET Library (using RTF specification)

来源:互联网 发布:mac文件储存位置 编辑:程序博客网 时间:2024/05/18 02:41

Gios WORD .NET Library (using RTF specification)

This is the output of "Example 1", included in the library.

DOWNLOAD

Introduction

The Gios WORD .NET is the second thing that a good C# developer needs to deploy in his business projects... The first one?!? You probably know it is theGios PDF .NET library!

So, that's why I decided to develop this library: after the need for generating PDFs, you will need the same for WORDs!

Gios WORD .NET是一个好的C#开发人员需要在商业项目中部署的第二件实物。也许你想问,第一个是什么呢? 也许你知道,Gios PDF .NET library!

这就是我选择开发这个库的原因:有需要生成PDF之后,你也许需要生成WORD。

Gios WORD .NET supports:

  • Tables with rows and columns span.
  • Images
  • Header and Footer
  • Line indent - paragraph
  • Custom Control Words (See the Rich Text Format (RTF) Specificationfor this implementation.)
  • Output to a generic System.IO.Stream object.

Gios WORD .NET 支持

  • 利用表格表示行列跨度
  • 图像
  • 页眉页脚
  • 行缩进-段落
  • 定制控件字符
  • 输出通用 System.IO.Stream 对象.

Background

Building a library for exporting documents in the Rich Text Format is quite easier than for PDFs. In fact, theRich Text Format (RTF) Specification, version 1.8shows how simple it is to generate a word document with all the well known features. I used the version 1.5 (which is fully compatible with WORD 97).

 

创建一个用RTF格式输出文档相对PDF来说是比较简单的。实际上, Rich Text Format (RTF) Specification, version 1.8  显示了用它去生成一个有众所周知特性的word文档。

Using the code

The library is very simple to be used! The first thing you need to do is instantiating a newWordDocument:

这个库是非常容易用的!你所要做的第一件事就是实例化一个 新WordDocument。

WordDocument myWordDocument=new WordDocument(WordDocumentFormat.Letter_8_5x11);

and with the WordDocument object you can start with the description of the document. It's like an automation. For example, if you want to set the font, you can write:

利用WordDocument对象,你可以描述文档。他看上去是自动化的。例如,你想设置字体,你可以写:

myWordDocument.SetFont(new Font("Comic Sans MS",60,FontStyle.Bold));myWordDocument.SetForegroundColor(Color.Red);myWordDocument.SetFontBackgroundColor(Color.Yellow);

And now we set some alignment:

现在我们设置一些对准:

myWordDocument.SetTextAlign(WordTextAlign.Center);

To write a text... You can imagine:

写一个文本:

myWordDocument.Write("Hello World!");

And, in the end, you output the document!

最后吗,你可以输出文档:

myWordDocument.SaveToFile("HelloWorld.doc");

And this is the result:

这是结果:

 

 

 

Remember, you can also output the WORD Document to a generic stream. These are the lines for a web response:

注意:你也可以输出WORD文档输出流。这是一个web应答:

Response.ClearHeaders();Response.AppendHeader("Content-disposition",   "attachment;filename=HelloWorld.doc");Response.ContentType="application/msword"; myPdfDocument.SaveToStream(Response.OutputStream);Response.End();

 

翻译自:

http://www.codeproject.com/Articles/11252/Gios-WORD-NET-Library-using-RTF-specification

版权属于原作者



出处:http://www.cnblogs.com/because/archive/2012/04/23/2467120.html

0 0
原创粉丝点击