我是一名实习的法国学生,我必须从 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 格式并将边距设置为表格居中。