私のaspxページの1つでExcelのダウンロードに問題があります。Excelのファイルサイズは256KBのみです。
1つのaspxページを除くすべてのaspxページからのファイルのダウンロード。なぜこれが起こっているのか理解できません。それだけでなく、DEVおよびQA環境でも機能しているだけでなく、同じコードを本番環境にプッシュしたときも機能します。動作していません。
更新
マスターページのメニュー項目でコードをダウンロードします。
MasterPage
ElseIf e.Item.Text = "Download" Then
ResponseHelper.DownloadExcel()
ResponseHelper.vb
Public Shared Sub DownloadExcel()GenerateData()End Sub Public Shared Sub GenerateData()Dim response As HttpResponse response = System.Web.HttpContext.Current.Response
Dim sqlDs As New DataSet
Dim sqlCmd As New SqlClient.SqlCommand
Dim sqlDa As New SqlClient.SqlDataAdapter
Dim SqlCnn As New SqlClient.SqlConnection(AppSettings("dbKey"))
--All ADO.Net statements here
If sqlDs.Tables(0).Rows.Count > 0 Then
Dim dtAllDownload As DataTable = sqlDs.Tables(0)
Dim dtChinaManufacturing As New DataTable
Dim dtChinaHealthcare As New DataTable
Dim dtChinaManagement As New DataTable
Dim dtChinaSelling As New DataTable
Dim dv As DataView
dv = New DataView(sqlDs.Tables(0), "GL_Source='Manufacturing'", "Id", DataViewRowState.CurrentRows)
dtChinaManufacturing = dv.ToTable
dv = New DataView(sqlDs.Tables(0), "GL_Source='Healthcare'", "Id", DataViewRowState.CurrentRows)
dtChinaHealthcare = dv.ToTable
dv = New DataView(sqlDs.Tables(0), "GL_Source='Management'", "Id", DataViewRowState.CurrentRows)
dtChinaManagement = dv.ToTable
dv = New DataView(sqlDs.Tables(0), "GL_Source='Selling'", "Id", DataViewRowState.CurrentRows)
dtChinaSelling = dv.ToTable
dv.Dispose()
Using pck As New ExcelPackage()
'Create the worksheets
Dim wsAll As ExcelWorksheet = pck.Workbook.Worksheets.Add("All")
Dim wsChinaManufacturing As ExcelWorksheet = pck.Workbook.Worksheets.Add("Manufacturing")
Dim wsChinaHealthcare As ExcelWorksheet = pck.Workbook.Worksheets.Add("Healthcare")
Dim wsChinaManagement As ExcelWorksheet = pck.Workbook.Worksheets.Add("Management")
Dim wsChinaSelling As ExcelWorksheet = pck.Workbook.Worksheets.Add("Selling")
'Load the datatable into the sheet, starting from cell A1. Print the column names on row 1
wsAll.Cells("A1").LoadFromDataTable(dtAllDownload, True)
If dtChinaManufacturing.Rows.Count > 0 Then
wsManufacturing.Cells("A1").LoadFromDataTable(dtManufacturing, True)
End If
If dtChinaHealthcare.Rows.Count > 0 Then
wsChinaHealthcare.Cells("A1").LoadFromDataTable(dtHealthcare, True)
End If
If dtChinaManagement.Rows.Count > 0 Then
wsChinaManagement.Cells("A1").LoadFromDataTable(dtManagement, True)
End If
If dtChinaSelling.Rows.Count > 0 Then
wsChinaSelling.Cells("A1").LoadFromDataTable(dtSelling, True)
End If
'wsAll.Cells(1, 1, dtAllDownload.Rows.Count - 1, dtAllDownload.Columns.Count).AutoFitColumns(30)
wsAll.defaultColWidth = 20
'Write it back to the client
Dim filename As String = "FullExtract_" & Now.Year.ToString & Now.Month.ToString & Now.Day.ToString & ".xlsx"
response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
response.AddHeader("content-disposition", "attachment; filename=" & filename)
response.BinaryWrite(pck.GetAsByteArray())
response.End()
End Using
End If
End Sub
このダウンロードでエラーが発生したAspxページ。
http://uploading.com/files/18b59f94/Observations.aspx/