【发布时间】:2012-01-04 04:50:16
【问题描述】:
实际导出没问题:
Response.Clear();
Response.ClearHeaders();
Response.Buffer = true;
Response.ContentType = "application/msword";
Response.AddHeader("Pragma", "public");
Response.AddHeader("Expires", "0");
Response.AddHeader("Content-Type", "application/word");
Response.AddHeader("content-disposition", String.Format("attachment;filename={0}.doc", docName));
Response.Charset = "utf-8";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
mainbody.RenderControl(hw);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
所以我的问题是:如何更改生成的 word doc 的边距?
如果我打开下载的 word doc 然后另存为 HTML,定义边距的指令是:
@page WordSection1
{
size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;
}
我想知道如何在响应标头中更改它,以便可以在一张纸上正确输出表单。有什么想法吗?
【问题讨论】:
-
这个运气好吗?我们正在生成一个包含图像的 html 文档,并且设置了右边距,因此隐藏了图像和文本。它实际上是表格列。
-
学习如何自己编写 HTML 比尝试让软件为你编写 HTML 更容易。
标签: html ms-word export margin