星空网 > 软件开发 > ASP.net

Spire.DOC生成表格测试

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

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

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

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

先看一下效果

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

  由于本人愚钝,第一次创建项目时,没有同时引用Spire.Doc和Spire.License两个文件,所以导致工程出错,给Jack添了不少麻烦。

  个人感觉相较于Office,Spire用起来还是很方便的,显示表头,只需要添加好的Header数组进行一个循环就可以,内容部分也差不多,就不写了。

Spire.DOC生成表格测试Spire.DOC生成表格测试
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提供了一个文件格式的枚举,可以让开发者方便的选择,当然,如果在提供前台选择页面的时候,也可以让用户来选择

 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,    //    // 摘要:    //       //    // 摘要:    //   Text file format.    Txt,    //    // 摘要:    //   Html format.    Html,    //    // 摘要:    //   XPS format    XPS,    //    // 摘要:    //   EPub format    EPub,    //    // 摘要:    //   WordprocessingML format    WordML,    //    // 摘要:    //   Word     Word//    // 摘要:    //   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,我的语言太拙劣了。

 




原标题:Spire.DOC生成表格测试

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流