Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET VB.NET table Word
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.
Posted 24-Jun-11 3:18am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
pcksalim at 25-Jun-11 6:49am
   
Hai Mr. Dave Kreskowiak,
 
You Are RIGHT. I got It.
 
Thank you very much.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 275
1 Maciej Los 230
2 Sergey Alexandrovich Kryukov 185
3 Afzaal Ahmad Zeeshan 152
4 ProgramFOX 130
0 OriginalGriff 6,524
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,218
3 Manas Bhardwaj 4,657
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 24 Jun 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100