Asp.net导出的问题,导出Word后,在WPS,Word2003,word2010里看到的都不一样?

Pretty夜晚 2014-07-30 09:15:00
Asp.net导出的问题,导出Word后,在WPS,Word2003,word2010里看到的都不一样?
在WPS里看到的字体是横着的,在Word2010里看到的字体往往比2003里的大的多,请问有什么办法能解决吗?
我的导出代码如下:

Response.Clear();
Response.Buffer = true;
Response.Charset = "UTF-8";
Response.HeaderEncoding = System.Text.Encoding.GetEncoding("UTF-8");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
Response.AppendHeader("content-disposition", "attachment;filename=\"" + HttpUtility.UrlEncode(Request["txtName"] + "-" + DateTime.Now.ToString("yyyy年MM月dd日"), System.Text.Encoding.UTF8) + ".doc\"");
Response.ContentType = "Application/ms-word";
Response.Write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
Response.Write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
Response.Write("<head>\n");
Response.Write("<style type=\"text/css\">" +
"\n body{background:#FFF;padding:0px;margin:20px;font-size:16px;font-family:@宋体;text-align:center;color:#000;} " +
"\n .pb{font-size:16px;border-collapse:collapse;width:90%;} " +
"\n .pb th{text-align:center;border:1px solid #000;padding:1px;font-weight:normal;} " +
"\n .pb td{border:1px solid #000;padding:1px;} " +
"\n .exportTitle{font-size:16px;font-weight:bold;margin:15px 0 5px 0;width:100%;text-align:center;} " +
"\n .exportCustomerName{font-size:16px;margin:5px 0 5px 0;width:100%;text-align:left;color:Red;} " +
"\n .exportDescription{font-size:16px;margin:5px 0 5px 0;width:100%;text-align:left;color:#000;} " +
"\n .exportDescription p{padding:0px;margin:0px;line-height:25px;} " +
"\n .exportDescription span{color:Red;} " +
"\n .exportWanner{font-size:16px;padding:15px 0px 5px 0px;width:100%;text-align:left;color:#000;} " +
"\n .exportWanner span{color:Red;} " +
"\n #exportContent{width:100%;text-align:left;} " +
"\n #exportCopy{width:auto;text-align:right;margin:15px 80px 0px 0px;} " +
"\n #exportCopy p{padding:5px 0px 0px 0px;margin:0px;} " +
"\n .exportLine{width:100%;height:1px;border-top:1px solid #000;margin:25px 0px 25px 0px;} " +
"\n #hzTitle{font-size:16px;font-weight:bold;padding:10px 0 5px 0;width:100%;text-align:center;display:block;} " +
"\n #hzName{font-size:16px;padding:10px 0 5px 0;width:100%;text-align:left;} " +
"\n #hzContent{font-size:16px;padding:5px 0 5px 0;width:100%;text-align:left;color:#000;} " +
"\n #hzContent input{border:0px;border-bottom:1px solid #000;width:120px;} " +
"\n #hzCopy{width:auto;text-align:right;padding-top:20px;} " +
"\n #hzCopy p{margin:5px 80px 0 0;padding:0px;}\n</style>\n ");
Response.Write("</head>\n");
Response.Write("<body>\n");
Response.Write("<div class=\"exportTitle\">对账单确认函</div>\n");
Response.Write("<div id=\"exportContent\">\n");
Response.Write("<div style=\"margin:0px 0px 5px 20px;\">\n");
Response.Write("" + Request["txtContent"] + "\n");
Response.Write("</div>\n");
Response.Write("</div>\n");
Response.Write("<div id=\"hzContent\">\n");
Response.Write("  \n");
Response.Write("经核对我单位与贵公司往来金额一致,往来款余额为:<u>    </u>(大写:<div></div>),专此确认。\n");
Response.Write("</div>\n");
Response.Write("<div id=\"hzCopy\">\n");
Response.Write("<p><input type=\"text\" />(单位签章)</p>\n");
Response.Write("<p style=\"padding-right:200px;\">  年  月  日</p>\n");
Response.Write("</div>\n");
Response.Write("</body>\n</html>");
Response.Flush();
Response.End();
...全文
84 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Pretty夜晚 2014-07-30
  • 打赏
  • 举报
回复
引用 1 楼 insus 的回复:
由于每个版本对样式支持有所改变。 是否考虑输出PDF文档。
不行啊,只能输出Word啊,这是要求的啊,在后台有什么办法针对这些版本分别设定样式啊?
insus 2014-07-30
  • 打赏
  • 举报
回复
由于每个版本对样式支持有所改变。 是否考虑输出PDF文档。

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧