0

つまり、私が行っているのは、epplusを使用してExcelファイルを作成し、それをresponse.outputstreamに保存することです。

何らかの理由でコードが壊れてエラーが発生します。何が間違っているのかわかりません。

Using package As New ExcelPackage(newFile)
        ' add a new worksheet to the empty workbook
        Dim worksheet As ExcelWorksheet = package.Workbook.Worksheets.Add("Analysis")
        Dim worksheet2 As ExcelWorksheet = package.Workbook.Worksheets.Add("Data")
        'Add the headers
        worksheet.Cells(1, 2).Value = "Key Performance Indicators"
        worksheet.Cells(1, 6).Value = MWHtotal & "MW Hours"
        worksheet.Cells(2, 3).Value = "Before Deslag"
        worksheet.Cells(2, 4).Value = "After Deslag"
        worksheet.Cells(2, 5).Value = "Percent Change"
        worksheet.Cells(2, 2).Value = aunit
        worksheet.Cells(2, 6).Value = auser & " analysis"

        worksheet.Cells(3, 2).Value = "Primary SuperHeat Draft Loss"
        worksheet.Cells(4, 2).Value = "Primary SuperHeat Draft Loss Rate"
        worksheet.Cells(5, 2).Value = "Zolo FEGT"
        worksheet.Cells(6, 2).Value = "Max Ramp Rate"
        worksheet.Cells(7, 2).Value = "Max Load"
        worksheet.Cells(8, 2).Value = "Throttle Set Pressure"
        worksheet.Cells(9, 2).Value = "Water Wall Cleanliness"
        worksheet.Cells(10, 2).Value = "Platen SH Cleanliness"
        worksheet.Cells(11, 2).Value = "SSH Cleanliness"
        worksheet.Cells(12, 2).Value = "SSH Delta Temp"
        worksheet.Cells(13, 2).Value = "Primary SH Cleanliness"
        worksheet.Cells(14, 2).Value = "SHT Attemp"
        worksheet.Cells(15, 2).Value = "DP Across SSH"
        worksheet.Cells(16, 2).Value = "RH Cleanliness"
        worksheet.Cells(17, 2).Value = "RH Delta Temp"
        worksheet.Cells(18, 2).Value = "RH Attemp"
        worksheet.Cells(19, 2).Value = "DP Across RH"
        worksheet.Cells(20, 2).Value = "Boiler Efficiency"
        worksheet.Cells(21, 2).Value = "Reheat Gas Temp(Above Horiz Reheater Grid)"
        worksheet.Cells(22, 2).Value = "Econ Gas Outlet Temp"
        worksheet.Cells(23, 2).Value = "Furnace Exit Gas Temp"
        worksheet.Cells(24, 2).Value = "East FEGT"
        worksheet.Cells(25, 2).Value = "West FEGT"
        worksheet.Cells(26, 2).Value = "Secondary SuperHeat Draft Loss"
        worksheet.Cells(27, 2).Value = "Vertical ReHeat Cleanliness Factor"
        worksheet.Cells(28, 2).Value = "Air Heat Gas Outlet Temp"
        worksheet.Cells(29, 2).Value = "Total Air Flow"
        worksheet.Cells(30, 2).Value = "MW"
        worksheet.Cells(3, 6).Value = "H2O"
        worksheet.Cells(4, 6).Value = "H2O/Min"
        worksheet.Cells(5, 6).Value = "Deg F"
        worksheet.Cells(6, 6).Value = "MW/Min"
        worksheet.Cells(7, 6).Value = "MW"
        worksheet.Cells(8, 6).Value = "Psig"
        worksheet.Cells(9, 6).Value = "Percent"
        worksheet.Cells(10, 6).Value = "Percent"
        worksheet.Cells(11, 6).Value = "Percent"
        worksheet.Cells(12, 6).Value = "Deg F"
        worksheet.Cells(13, 6).Value = "Percent"
        worksheet.Cells(14, 6).Value = "lb/hr"
        worksheet.Cells(15, 6).Value = "H2O"
        worksheet.Cells(16, 6).Value = "Percent"
        worksheet.Cells(17, 6).Value = "Deg F"
        worksheet.Cells(18, 6).Value = "lb/hr"
        worksheet.Cells(19, 6).Value = "H2O"
        worksheet.Cells(20, 6).Value = "Percent"
        worksheet.Cells(21, 6).Value = "Deg F"
        worksheet.Cells(22, 6).Value = "Deg F"
        worksheet.Cells(23, 6).Value = "Deg F"
        worksheet.Cells(24, 6).Value = "Deg F"
        worksheet.Cells(25, 6).Value = "Deg F"
        worksheet.Cells(26, 6).Value = "H2O"
        worksheet.Cells(27, 6).Value = "Percent"
        worksheet.Cells(28, 6).Value = "Deg F"
        worksheet.Cells(29, 6).Value = "KPPH"
        worksheet.Cells(30, 6).Value = "MW"
        arraycol = 0
        arrayrow = 0
        For i = 0 To pdata.Count
            worksheet2.Cells(arrayrow + 1, arraycol + 1).Value = PIArray(arrayrow, arraycol)
        Next

        worksheet.Cells(3, 3).Value = wa
        worksheet.Cells(4, 3).Value = za
        worksheet.Cells(5, 3).Value = ua
        worksheet.Cells(6, 3).Value = amaxrate
        worksheet.Cells(7, 3).Value = amax
        worksheet.Cells(8, 3).Value = ta
        worksheet.Cells(9, 3).Value = aa
        worksheet.Cells(10, 3).Value = ba
        worksheet.Cells(11, 3).Value = ca
        worksheet.Cells(12, 3).Value = da
        worksheet.Cells(13, 3).Value = ea
        worksheet.Cells(14, 3).Value = fa
        worksheet.Cells(15, 3).Value = ga
        worksheet.Cells(16, 3).Value = ha
        worksheet.Cells(17, 3).Value = ia
        worksheet.Cells(18, 3).Value = ja
        worksheet.Cells(19, 3).Value = ka
        worksheet.Cells(20, 3).Value = la
        worksheet.Cells(21, 3).Value = ma
        worksheet.Cells(22, 3).Value = na
        worksheet.Cells(23, 3).Value = oa
        worksheet.Cells(24, 3).Value = qa
        worksheet.Cells(25, 3).Value = ra
        worksheet.Cells(26, 3).Value = xa
        worksheet.Cells(27, 3).Value = ya
        worksheet.Cells(28, 3).Value = pa
        worksheet.Cells(29, 3).Value = sa
        worksheet.Cells(30, 3).Value = va
        worksheet.Cells(3, 4).Value = wb
        worksheet.Cells(4, 4).Value = zb
        worksheet.Cells(5, 4).Value = ub
        worksheet.Cells(9, 4).Value = ab
        worksheet.Cells(10, 4).Value = bb
        worksheet.Cells(11, 4).Value = cb
        worksheet.Cells(12, 4).Value = db
        worksheet.Cells(13, 4).Value = eb
        worksheet.Cells(14, 4).Value = fb
        worksheet.Cells(15, 4).Value = gb
        worksheet.Cells(16, 4).Value = hb
        worksheet.Cells(17, 4).Value = ib
        worksheet.Cells(18, 4).Value = jb
        worksheet.Cells(19, 4).Value = kb
        worksheet.Cells(20, 4).Value = lb
        worksheet.Cells(21, 4).Value = mb
        worksheet.Cells(22, 4).Value = nb
        worksheet.Cells(23, 4).Value = ob
        worksheet.Cells(24, 4).Value = qb
        worksheet.Cells(25, 4).Value = rb
        worksheet.Cells(26, 4).Value = xb
        worksheet.Cells(27, 4).Value = yb
        worksheet.Cells(28, 4).Value = pb
        worksheet.Cells(29, 4).Value = sb
        worksheet.Cells(30, 4).Value = vb
        worksheet.Cells(3, 5).Value = wpercent
        worksheet.Cells(4, 5).Value = zpercent
        worksheet.Cells(5, 5).Value = upercent
        worksheet.Cells(9, 5).Value = apercent
        worksheet.Cells(10, 5).Value = bpercent
        worksheet.Cells(11, 5).Value = cpercent
        worksheet.Cells(12, 5).Value = dpercent
        worksheet.Cells(13, 5).Value = epercent
        worksheet.Cells(14, 5).Value = fpercent
        worksheet.Cells(15, 5).Value = gpercent
        worksheet.Cells(16, 5).Value = hpercent
        worksheet.Cells(17, 5).Value = ipercent
        worksheet.Cells(18, 5).Value = jpercent
        worksheet.Cells(19, 5).Value = kpercent
        worksheet.Cells(20, 5).Value = lpercent
        worksheet.Cells(21, 5).Value = mpercent
        worksheet.Cells(22, 5).Value = npercent
        worksheet.Cells(23, 5).Value = opercent
        worksheet.Cells(24, 5).Value = qpercent
        worksheet.Cells(25, 5).Value = rpercent
        worksheet.Cells(26, 5).Value = xpercent
        worksheet.Cells(27, 5).Value = ypercent
        worksheet.Cells(28, 5).Value = ppercent
        worksheet.Cells(29, 5).Value = spercent
        worksheet.Cells(30, 5).Value = vpercent
        worksheet.Cells(3, 7).Value = wcolor
        worksheet.Cells(4, 7).Value = zcolor
        worksheet.Cells(5, 7).Value = ucolor
        worksheet.Cells(9, 7).Value = acolor
        worksheet.Cells(10, 7).Value = bcolor
        worksheet.Cells(11, 7).Value = ccolor
        worksheet.Cells(12, 7).Value = dcolor
        worksheet.Cells(13, 7).Value = ecolor
        worksheet.Cells(14, 7).Value = fcolor
        worksheet.Cells(15, 7).Value = gcolor
        worksheet.Cells(16, 7).Value = hcolor
        worksheet.Cells(17, 7).Value = icolor
        worksheet.Cells(18, 7).Value = jcolor
        worksheet.Cells(19, 7).Value = kcolor
        worksheet.Cells(20, 7).Value = lcolor
        worksheet.Cells(21, 7).Value = mcolor
        worksheet.Cells(22, 7).Value = ncolor
        worksheet.Cells(23, 7).Value = ocolor
        worksheet.Cells(24, 7).Value = qcolor
        worksheet.Cells(25, 7).Value = rcolor
        worksheet.Cells(26, 7).Value = xcolor
        worksheet.Cells(27, 7).Value = ycolor
        worksheet.Cells(28, 7).Value = pcolor
        worksheet.Cells(29, 7).Value = scolor
        worksheet.Cells(30, 7).Value = vcolor

        Response.Clear()

        Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
        Response.AppendHeader("Content-Disposition", "attachment;filename=analyze.xlsx")
        package.SaveAs(Response.OutputStream)

        Response.End()
    End Using

このエラーが発生します

0x800a139e-Microsoft JScriptランタイムエラー:Sys.WebForms.PageRequestManagerParserErrorException:サーバーから受信したメッセージを解析できませんでした。

4

1 に答える 1

1

おそらくこれをUpdatePanelまたはAjax呼び出しから呼び出します-しかし、応答ヘッダーをクリアするためにそれを行うと、ajaxが返されるのを待つjsonの代わりに、別の何かを送信します(ここにxlsxファイルがあります)-そしてあなたはそのメッセージを受け取ります、それはその優れたものを解析することはできません。

ajaxまたはUpdatePanelは、このファイルのような別のファイルを送信しようとしていることを理解できません。このファイルを送信するetherハンドラーを作成し、それをハイパーリンクに配置して、UpdatePanelを削除する必要があります。

于 2012-12-13T18:20:44.867 に答える