专家您好,
我创建一个Web应用程序包含很多要生成的报告。我动态创建一个"表",并添加"TR"和"TD"根据从数据库中的记录追加到字符串生成器,最后分配的字符串的innerHTML Div标签。
我要为用户提供导出到Excel表和我能够出口的内容包括使用下面的代码时,它是一个单独的页面的CSS样式。但下面的代码是无法正常工作,当我去为内容页(母版页)。
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.Charset = ""
GenerateEvalReport() ' Generating the Table here and assigning to DIV.InnerHTML
Response.AddHeader("content-disposition", "EvalReport.xls")
Response.ContentType = "application/vnd.ms-excel"
' Response.ContentType = "application/ms-excel" -- Tried this also. Not Working
Dim objRow As New HtmlTableRow
Dim objCell As New HtmlTableCell
objCell.Controls.Add(tblBody) ' 'tblBody'- Id of my Dynamic Table
objRow.Cells.Add(objCell)
table1.Rows.Add(objRow) ' Have one more Table as 'table1'
table1.RenderControl(oHTMLTextWrite)
Response.Write(oStringWriter.ToString())
Response.Flush()
Response.End()
我得到两个不同的错误(因为我已经使用相同的代码在2页)当使用Response.Write(oStringWriter.ToString())
1。 Sys.WebForms.PageRequestManagerParserErrorException:从服务器收到的消息无法解析
2。无法评估的表达。主题中止。
可以请你指出我哪里犯的错误。
非常感谢。