导出到Excel时遇到ASP.net VB.net错误 [英] ASP.net VB.net Error Encountered when exporting to excel

查看:92
本文介绍了导出到Excel时遇到ASP.net VB.net错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


大家好,
希望您能帮助我解决我的问题
我是应届毕业生,现在正在一家好公司做开发人员
顺便说一下,我不是开发此工具的人,而是以前的程序员,他们把项目交给我进行了更新
但是,当我尝试在本地计算机上运行该应用程序时,出现此错误:

未为公共子新建(XMLFile作为字符串,XLSFile作为字符串)"的参数"XLSFile"指定参数.


错误指向以下粗体字母代码:
受保护的子Button1_Click(ByVal发送者作为对象,ByVal e作为System.EventArgs)处理Button1.Click
Zym.ConnectionString = Web.Configuration.WebConfigurationManager.ConnectionStrings("cnworkload").ConnectionString
''Dim cn为System.Data.SqlClient.SqlConnection =新的System.Data.SqlClient.SqlConnection(Zym.ConnectionString)
''将DA用作新的System.Data.SqlClient.SqlDataAdapter("SELECT * FROM Summary_WORKLOAD",cn)
''将DS昏暗为System.Data.DataSet =新的System.Data.DataSet
试试
excel =新的zymClass.myCustomClass.Excel(Server.MapPath(Request.ApplicationPath)&"\ Export \ ExportPivot.xlsx")

excel.ConnectionString = Web.Configuration.WebConfigurationManager.ConnectionStrings("cnworkload").ConnectionString
excel.STRSQL =选择*来自summary_WORKLOAD"
excel.Connect()
''cn.Open()
''DA.Fill(DS)
''excel.ExportRawData(DS)
excel.Sheetname =原始数据"
excel.SetPageField("CORPORATE")
excel.SetRowField("BUSGROUP","TEAM")
excel.SetRowName(业务组或公司",团队")
excel.SetRowSummary(True,False)
excel.SetRowGrandtotal(False)
excel.SetColumnField("YEAR","MONTH")
excel.SetColumnName(年",月")
excel.SetColumnSummary(False,False)
excel.SetColumnGrandtotal(False)
excel.SetDataField(小时")
excel.SetDataName(小时数")
excel.SetDataFormat("0")
excel.SetDataConsolidation(Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlCount)
excel.ExportPivot("OLEDB; Provider = SQLOLEDB;",excel.STRSQL,工作负载数据")
异常捕获
结束尝试
Zym.ZipFile("/C zip""& HttpContext.Current.Server.MapPath(〜/export/exportpivot.zip")&""& HttpContext.Current.Server.MapPath(" 〜/export/exportpivot.xlsx)&"",HttpContext.Current.Server.MapPath(〜/export"))
Response.Redirect("FILE.ASPX")
结束子


我真的希望有人能帮助我,我已经对自己说,哭泣不是解决这个问题的关键:((... ...
提前非常感谢您,并告诉我是否需要查看整个.aspx和.vb代码,以便我为您提供帮助.

Hi everyone,
I hope you could help me with my problem
I am a fresh graduate and I am working now as a developer in a good company
By the way, I am not the one who developed this tool, it''s the previous programmer and they gave the project to me to update it
however, when I try to run the application in my local computer I am getting this error:

Argument not specified for parameter ''XLSFile'' of ''Public Sub New(XMLFile As String, XLSFile As String)''.


The error points to the code below in bold letter:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Zym.ConnectionString = Web.Configuration.WebConfigurationManager.ConnectionStrings("cnworkload").ConnectionString
''Dim cn As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(Zym.ConnectionString)
''Dim DA As New System.Data.SqlClient.SqlDataAdapter("SELECT * FROM SUMMARY_WORKLOAD", cn)
''Dim DS As System.Data.DataSet = New System.Data.DataSet
Try
excel = New zymClass.myCustomClass.Excel(Server.MapPath(Request.ApplicationPath) & "\Export\ExportPivot.xlsx")

excel.ConnectionString=Web.Configuration.WebConfigurationManager.ConnectionStrings("cnworkload").ConnectionString
excel.STRSQL = "SELECT * FROM SUMMARY_WORKLOAD"
excel.Connect()
''cn.Open()
''DA.Fill(DS)
''excel.ExportRawData(DS)
excel.Sheetname = "RAW DATA"
excel.SetPageField("CORPORATE")
excel.SetRowField("BUSGROUP", "TEAM")
excel.SetRowName("Business Group or Corporate", "Team")
excel.SetRowSummary(True, False)
excel.SetRowGrandtotal(False)
excel.SetColumnField("YEAR", "MONTH")
excel.SetColumnName("Year", "Month")
excel.SetColumnSummary(False, False)
excel.SetColumnGrandtotal(False)
excel.SetDataField("Hours")
excel.SetDataName("Count of Hours")
excel.SetDataFormat("0")
excel.SetDataConsolidation(Microsoft.Office.Interop.Excel.XlConsolidationFunction.xlCount)
excel.ExportPivot("OLEDB;Provider=SQLOLEDB;", excel.STRSQL, "Workload Data")
Catch ex As Exception
End Try
Zym.ZipFile(" /C zip """ & HttpContext.Current.Server.MapPath("~/export/exportpivot.zip") & """ """ & HttpContext.Current.Server.MapPath("~/export/exportpivot.xlsx") & """", HttpContext.Current.Server.MapPath("~/export"))
Response.Redirect("FILE.ASPX")
End Sub


I really hope someone can help me, I already said to myself that crying is not the key to solve this :(( ....
Thank you very much in advance and tell me if you need to see the whole .aspx and .vb code so that I can provide you.

推荐答案

希望 [
Hope this[^] might help you to solve your problem.


这篇关于导出到Excel时遇到ASP.net VB.net错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆