【问题标题】:Set margins and properties of word document while export HTML Table in c#在c#中导出HTML表格时设置word文档的边距和属性
【发布时间】:2013-08-10 00:16:18
【问题描述】:

我是一名实习的法国学生,我需要从 HTML 表格中导出一个单词。

我得到了我的Table tableContent = new Table(),我正在使用这种方法进行导出:

Response.Clear();
Response.Buffer = true;
Response.Write(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0           Transitional//EN"">");
Response.AddHeader("content-disposition", "attachment;filename=DataTable.doc");
Response.ContentType = "application/msword";
String style = "<style>body {margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size:11px;}</style>";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
tableContent.RenderControl(hw);
Response.Charset = "ISO-8859-1";
Response.ContentEncoding = System.Text.Encoding.GetEncoding(1252);
Response.HeaderEncoding = System.Text.Encoding.GetEncoding(1252);
Response.Write(style);
Response.Write(sw.ToString());
Response.Flush();
Response.End();

但是当我阅读我的 wordfile (.doc) 时,选择的视图是 word 中的“Web”,当我选择 "Page" 视图时,我的表格没有居中导致巨大的左边距。

我想知道是否可以将我的 word 文档设置为 A4 格式并将边距设置为表格居中。

【问题讨论】:

    标签: html ms-word format export margin


    【解决方案1】:

    它用于将表格的边距设置为中心

    *
        {
            margin:0px;
            padding:0px;
    
            }
            #all
                {
    
                    width:100%;
                    margin:0px;
    
                    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-07
      • 1970-01-01
      • 2011-12-24
      • 1970-01-01
      • 2021-12-09
      • 2012-01-04
      • 1970-01-01
      相关资源
      最近更新 更多