导出以生成正确的.DOC文件,该文件也可以在Word2007中读取 [英] Export to Produce Proper .DOC file which is Readable in Word2007 too

查看:139
本文介绍了导出以生成正确的.DOC文件,该文件也可以在Word2007中读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Web Developer2008.我在ASP.NET中有一个asp:Table,我可以通过渲染到HTML将该表导出为.doc(Word 97-2003)格式.但是该文件无法使用Word 2007打开,但可以在Word-2003中打开,并且可以另存为正确的.doc文件.然后它也可以在Word2007中打开.
在Word 2007中,适当的.doc就足够了.

不幸的是,我的客户端仅使用Word2007,并且在使用Word2007的系统中,带有Response.Write(Writer)的My Export给.doc文件提供了不可读的文本,如下所示:

+ ADw表ID + AD0AIg-Table1 + ACI-cellspacing + AD0AIg-0 + ACI-cellpadding + AD0AIg-1 + ACI-align + AD0AIg-Center + ACI-bordercolor + AD0AIgAj-000099 + ACI-border + AD0AIg-0 + ACI样式+ AD0AI颜色:+ ACM-000099 + ADs背景颜色:白色+ ADs边框颜色:+ ACM-000099 + ADs边框宽度:2px + ADs边框样式:Double + ADs- font-weight:bold + ADs-width:100 + ACUAOw-border-collapse:collapse + ADsAIgA +-+ + ADw-tr


如果它也可以在Word2007中产生可读的htm-doc内容(现在可以在Word2003中打开但在Word2007中不能打开),并且可以另存为正确的.doc文件,则我将对此感到满意.代码如下:

Response.Clear()
Response.Buffer = True
Response.ContentType =应用程序/msword"
Response.AddHeader("Content-Disposition","attachment; filename = WORK_ORDER.doc")
Response.ContentEncoding = System.Text.Encoding.UTF7
Response.Charset ="
EnableViewState = False

昏暗的作家作为新的System.IO.StringWriter()
变暗html作为新System.Web.UI.HtmlTextWriter(writer)
Table1.RenderControl(html)
Response.Write(writer)
Response.End()

此代码未提供在Word2007中提供可读的htm-doc内容,但仅在Word97-2003中提供"

如果有人可以帮助我,请产生在Word2007中也可读的正确的.DOC文件.

请.....

在此先感谢您.

I''m using Visual Web Developer 2008. I have an asp:Table in ASP.NET and I could Export that Table to .doc (Word 97-2003) formats by Rendering to Html. But That file cannot open using Word 2007, but can open in Word-2003 and could SaveAs proper .doc file. Then it can Open in Word2007 too.
Proper .doc is sufficient in Word 2007.

Unfortunately my client using Word2007 only and in systems with Word2007, My Export with Response.Write(Writer) gives .doc file with unreadable Text like below:

+ADw-table id+AD0AIg-Table1+ACI- cellspacing+AD0AIg-0+ACI- cellpadding+AD0AIg-1+ACI- align+AD0AIg-Center+ACI- bordercolor+AD0AIgAj-000099+ACI- border+AD0AIg-0+ACI- style+AD0AIg-color:+ACM-000099+ADs-background-color:White+ADs-border-color:+ACM-000099+ADs-border-width:2px+ADs-border-style:Double+ADs-font-weight:bold+ADs-width:100+ACUAOw-border-collapse:collapse+ADsAIgA+- +ADw-tr


I will be Satisfied with the below code If it can produce readable htm-doc content in Word2007 also (Now openable in Word2003 But Not in Word2007) which can SaveAs Proper .doc file. The code is given below:

Response.Clear()
Response.Buffer = True
Response.ContentType = "Application/msword"
Response.AddHeader("Content-Disposition","attachment; filename=WORK_ORDER.doc")
Response.ContentEncoding = System.Text.Encoding.UTF7
Response.Charset = ""
EnableViewState = False

Dim writer As New System.IO.StringWriter()
Dim html As New System.Web.UI.HtmlTextWriter(writer)
Table1.RenderControl(html)
Response.Write(writer)
Response.End()

This code Not providing "readable htm-doc content in Word2007, but in Word97-2003 only"

If anybody can help me pls to Produce Proper .DOC file which is Readable in Word2007 too.

Pls .....

Thanks in advance.

推荐答案

您的代码没有为任何版本的Word编写正确的.DOC文件. .DOC文件不应包含HTML,但这就是您要写的内容.

我的第一个怀疑是UTF7编码.将其更改为UTF8,然后重试.
Your code isn''t writing a proper .DOC file for any version of Word. A .DOC file is not expected to contain HTML, but that''s what you''re writing out.

My first suspect would be the UTF7 encoding. Change it to UTF8 and try it again.


这篇关于导出以生成正确的.DOC文件,该文件也可以在Word2007中读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆