【问题标题】:Response.ContentType = "application/vnd.ms-word"Response.ContentType = "应用程序/vnd.ms-word"
【发布时间】:2016-12-26 09:25:10
【问题描述】:

我正在将 html 内容(用户键入的内容-段落-hmtl 页面)导出到 MS-word(doc)。当我使用 C# Click 事件将内容导出到 word 时。它的工作正常。但它的内容周围有一些蓝色边框。 enter image description here

 Response.Clear();
    Response.Buffer = true;
    Response.AddHeader("content-disposition", "attachment;filename=" + Candidatename + "_" + filename + ".doc");
    Response.ContentType = "application/vnd.ms-word";
    tb = new Table();
    TableRow tr1 = new TableRow();
    TableCell cell1 = new TableCell();
    tr1.Attributes.Add("style", "border: 0px");
    tb.Attributes.Add("style", "border: 0px");
    cell1.Attributes.Add("style", "border: 0px");
    cell1.Text = Convert.ToString(str);
    tr1.Cells.Add(cell1);
    tb.Rows.Add(tr1);


    StringWriter sw = new StringWriter();
    HtmlTextWriter hw = new HtmlTextWriter(sw);
    tb.RenderControl(hw);

变量“str”从sql server中获取值(用户在文本区控件中输入的动态数据。

【问题讨论】:

    标签: html c#-4.0


    【解决方案1】:

    这是一个表格,里面有内容。

    如果您单击 Layout / View Gridlines,它们已被激活,您将停用它们并且这些线消失。 当您打印该文档时,将不会打印这些行

    【讨论】:

      猜你喜欢
      • 2016-11-22
      • 2016-02-08
      • 2019-03-22
      • 2012-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多