将aspx转换为word时出现问题,它在底部显示额外的行 [英] There is a problem in converting aspx to word it shows extra line in the bottom

查看:91
本文介绍了将aspx转换为word时出现问题,它在底部显示额外的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试将aspx转换为单词时底部没有行,但是当我进行打印时,它会在底部显示一行。我想删除该行请帮助我。

When i try to convert aspx to word There is no line at the bottom , but when i make a print it shows a line at the bottom. i want to remove that line Please help me.

StringBuilder sb = new StringBuilder();
            StringWriter tw = new StringWriter(sb);
            HtmlTextWriter hw = new HtmlTextWriter(tw);
            Page.RenderControl(hw);
            //var html = sb.ToString();
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Charset = "";
            HttpContext.Current.Response.ContentType = "application/msword";
            string strFileName = "Draft_" + "" + lblcertificateno.Text + " " + ".doc";

          

            HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName);
           
            HttpContext.Current.Response.Write(sb.ToString());

            HttpContext.Current.Response.End();
            HttpContext.Current.Response.Flush();





我尝试过:



我试过HtmlTextWriter hw = new HtmlTextWriter(tw);渲染控件以生成word文档。生成了文档,但它显示了底部的额外行。



What I have tried:

I have tried with the HtmlTextWriter hw = new HtmlTextWriter(tw); render control to generate the word document. Document generated but it shows the extra line at the bottom.

推荐答案

有一点要记住。您实际上并没有使用此方法生成word文档。你正在做的是生成一个扩展名为doc的HTML文件。



你应该看一下使用来自MS的Open XML SDk,欢迎使用Open XML SDK 2.5 for Office [ ^ ]或其中一个Office Automation组件。



您可以参考这篇CP文章, C#:创建和使用DocX以编程方式处理Word文档 [ ^ ]
There is one point to keep in mind. You are not really generating a word document using this methods. What you are doing is generating a HTML file with an extension of doc.

You should look at using is the Open XML SDk from MS, Welcome to the Open XML SDK 2.5 for Office[^] or one of the Office Automation components.

You can reference this CP article, C#: Create and Manipulate Word Documents Programmatically Using DocX[^]


这篇关于将aspx转换为word时出现问题,它在底部显示额外的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆