Spire.DOC生成表格测试

  首先,很感谢Jack对个人信任,让我来写一个评测,在此对Jack说一声抱歉,因为本人愚钝,而且最近项目比较紧张,把评测这个事情脱了一个月之久,因为日后的日子可能更忙,因此今晚抽空只能只写了一个小程序来测试。程序员

  Spire系列的Word,PDF,Excel,Presentation是一套专为.NET开发人员设计的控件。使用该套工具,程序员能够在任意.NET平台上对Office文件、PDF文档进行生成,读取,编辑,修改,转换格式等处理,且不须要安装MS Office
小程序

  红字部分的内容,是有Jack给我发邮件的时候,里面的内容,最让我心动的是最后一句话,不须要安装MS Office,你们都知道,Office是很大的,若是不用Office是最好的。数组

可是在写小例子的过程当中,发现,须要有有一个DOC的模板共DLL打开,才能写入内容,也就是说在没有模板的状况下,是不能够的。从侧面想一下,就是若是个人机器上只装了WPS也是能够进行Word开发的(固然,这是个人假象,没有实际测试。)ide

先看一下效果工具

  因为发给个人是测试版的DLL文件,因此在生成的Word上面会有“Evaluation Warning : The document was created with Spire.Doc for .NET.”红字的提示,这个倒不是很重要,下面的表格,就是我用Spire.Doc.dll生成的。测试

  因为本人愚钝,第一次建立项目时,没有同时引用Spire.Doc和Spire.License两个文件,因此致使工程出错,给Jack添了很多麻烦。lua

  我的感受相较于Office,Spire用起来仍是很方便的,显示表头,只须要添加好的Header数组进行一个循环就能够,内容部分也差很少,就不写了。spa

TableRow row = table.Rows[0];
 row.IsHeader = true;
 row.Height = 25f;
 for(int i=0;i<header.Length;i++)
 {
 row.Cells[i].CellFormat.VerticalAlignment = Spire.Doc.Documents.VerticalAlignment.Middle;
 Paragraph p = row.Cells[i].AddParagraph();
 p.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;
TextRange textRange = p.AppendText(header[i]);
textRange.CharacterFormat.Bold = true;
}
Header Code

  在保存Word的时候,能够直接调用Document下的一个保存方法SaveToFile设计

public void SaveToFile(string fileName, FileFormat fileFormat);

  我的认为方便的是FileFormat提供了一个文件格式的枚举,可让开发者方便的选择,固然,若是在提供前台选择页面的时候,也可让用户来选择3d

 public enum FileFormat
    {
        //
        // 摘要:
        //     Microsoft Word 97 - 2003 Binary Document.
        Doc,
        //
        // 摘要:
        //     Microsoft Word 97 - 2003 Binary Document or Template.
        Dot,
        //
        // 摘要:
        //     Microsoft Word 2007 Document.
        Docx,
        //
        // 摘要:
        //     Microsoft Word 2010 Document
        Docx2010,
        //
        // 摘要:
        //     Microsoft Word 2013 Document
        Docx2013,
        //
        // 摘要:
        //     Microsoft Word 2007 Template format.
        Dotx,
        //
        // 摘要:
        //     Microsoft Word 2010 Template format.
        Dotx2010,
        //
        // 摘要:
        //     Microsoft Word 2013 Template format.
        Dotx2013,
        //
        // 摘要:
        //     Microsoft Word 2007 macro enabled file format.
        Docm,
        //
        // 摘要:
        //     Microsoft Word 2010 macro enabled file format.
        Docm2010,
        //
        // 摘要:
        //     Microsoft Word 2013 macro enabled file format.
        Docm2013,
        //
        // 摘要:
        //     Microsoft Word 2007 macro enabled template format.
        Dotm,
        //
        // 摘要:
        //     Microsoft Word 2010 macro enabled template format.
        Dotm2010,
        //
        // 摘要:
        //     Microsoft Word 2013 macro enabled template format.
        Dotm2013,
        //
        // 摘要:
        //     PDF format
        PDF,
        //
        // 摘要:
        //     Rtf format
        Rtf,
        //
        // 摘要:
        //     Xml file format.
        Xml,
        //
        // 摘要:
        //     Text file format.
        Txt,
        //
        // 摘要:
        //     Html format.
        Html,
        //
        // 摘要:
        //     XPS format
        XPS,
        //
        // 摘要:
        //     EPub format
        EPub,
        //
        // 摘要:
        //     WordprocessingML format
        WordML,
        //
        // 摘要:
        //     Word xml format.
        WordXml,
        //
        // 摘要:
        //     The document is in the Word 6 or Word 95 format. Spire.Doc does not currently
        //     support loading such documents.
        DocPre97,
        //
        // 摘要:
        //     Instructs Spire.Doc to recognize the format automatically.
        Auto
    }

该睡觉了,就写到这吧,实在抱歉了Jack,个人语言太拙劣了。

相关文章
相关标签/搜索