我遇到了一个小任务。我的任务是导出数据集值以使用Xsl技术优秀。假设数据集中有四个数据表(分别为Table,Table1,Table2和Table3)。请注意,当我运行此代码时,我的本地机器工作正常。但不是在服务器机器上。我得到了以下信息 "无法加载网页,因为服务器未发送任何数据。 重新加载此网页。 按重新加载按钮重新提交加载页面所需的数据。 错误代码:ERR_EMPTY_RESPONSE"
void GenerateLeaveReport(string type)
{
DataSet ds = new DataSet();
IAttendanceHandler antHandler = new AttendanceHandler(_masterPage.Controller);
XmlDocument report = new XmlDocument();
//int department = Convert.ToInt32(ddlDepartment.SelectedValue.ToString());
int month = Convert.ToInt32(ddlMonth.SelectedValue.ToString());
int year = Convert.ToInt32(txtYear.Text.ToString());
string month_name = ddlMonth.SelectedItem.ToString();
try
{
ds = antHandler.GetAttendaceLeaveReport(month, year);
if (ds.Tables[0].Rows.Count > 0)
{
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
XmlDataDocument xmlDoc = new XmlDataDocument(ds);
XslCompiledTransform xslTran = new XslCompiledTransform();
xslTran.Load(Server.MapPath("../xsl/LeaveReport.xsl"));
// xslTran.Load(Server.MapPath("../xsl/LeaveReport1.xsl"));
// Program flow does not cross this line, is there any error in
// Response.OutputStream.
xslTran.Transform(xmlDoc, null, Response.OutputStream);
Response.AppendHeader("Content-Type", "application/vnd.ms-excel");
string fn = "LeaveReport" + "-" + month_name+"-"+year.ToString();
Response.AppendHeader("Content-disposition", "attachment; filename=" + fn + ".xls");
Response.End();
}
}
catch
{
// Error message
}
}
关心Sarva