NursingCorp
asked on
ASP.NET Form Export to Word CSS Settings
Hello Experts,
I have a button click event that will export my datagrid to a word document. The code works to bring the information out, but it is not applying my css styles that I have defined. Is there a way that I can replace the css style that is created with the export my css defined in the /Portals/0/portal.css file. (see attached code for button click).
I have a button click event that will export my datagrid to a word document. The code works to bring the information out, but it is not applying my css styles that I have defined. Is there a way that I can replace the css style that is created with the export my css defined in the /Portals/0/portal.css file. (see attached code for button click).
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Response.AddHeader("content-disposition", "attachment;filename=Export.doc")
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = "application/vnd.word"
Dim stringWrite As New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
Dim fi As FileInfo = New FileInfo(Server.MapPath("Portals/0/portal.css"))
Dim sb As New System.Text.StringBuilder
Dim sr As StreamReader = fi.OpenText()
Do While sr.Peek() >= 0
sb.Append(sr.ReadLine())
Loop
sr.Close()
' Create a form to contain the grid
Dim frm As New HtmlForm()
applicationGrid.Parent.Controls.Add(frm)
frm.Attributes("runat") = "server"
frm.Controls.Add(applicationGrid)
frm.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString())
Response.[End]()
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER