Protected Sub lnkExport_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles lnkExport.Click
Try
Me.ThisPage = Session("PageName")
Dim dv As DataView = New DataView(CurrentGridData.Tables(0))
gvCaseView.AllowPaging = False
gvCaseView.MasterTableView.DataSource = dv
IsExport = True
gvCaseView.MasterTableView.DataBind()
' Determine where grid was built in order to not export certain columns
If CurrentViewID = "NEW" Then
' Grid built in GetBoundColumnsForCustomer
If alUtil.CheckPermission("SUBMITCASES") Then
' Additional columns are added for this permission
Me.gvCaseView.MasterTableView.Columns(0).Visible = False
Me.gvCaseView.MasterTableView.Columns(1).Visible = False
Me.gvCaseView.MasterTableView.Columns(2).Visible = False
Me.gvCaseView.MasterTableView.Columns(3).Visible = False
Me.gvCaseView.MasterTableView.Columns(4).Visible = False
Me.gvCaseView.MasterTableView.Columns(5).Visible = False
Me.gvCaseView.MasterTableView.Columns(6).Visible = False
Me.gvCaseView.MasterTableView.Columns(8).Visible = False
Else
Me.gvCaseView.MasterTableView.Columns(0).Visible = False
Me.gvCaseView.MasterTableView.Columns(1).Visible = False
Me.gvCaseView.MasterTableView.Columns(3).Visible = False
End If
Else
' Grid built in GetBoundColumns
Me.gvCaseView.MasterTableView.Columns(0).Visible = False
Me.gvCaseView.MasterTableView.Columns(1).Visible = False
Me.gvCaseView.MasterTableView.Columns(2).Visible = False
Me.gvCaseView.MasterTableView.Columns(3).Visible = False
Me.gvCaseView.MasterTableView.Columns(4).Visible = False
Me.gvCaseView.MasterTableView.Columns(5).Visible = False
Me.gvCaseView.MasterTableView.Columns(6).Visible = False
Me.gvCaseView.MasterTableView.Columns(7).Visible = False
Me.gvCaseView.MasterTableView.Columns(8).Visible = False
Me.gvCaseView.MasterTableView.Columns(9).Visible = False
Me.gvCaseView.MasterTableView.Columns(11).Visible = False
End If
If Not Me.gvCaseView.MasterTableView.Columns.FindByUniqueNameSafe("completedIcon") Is Nothing Then
Me.gvCaseView.MasterTableView.GetColumn("completedIcon").Visible = False
End If
If Not Me.gvCaseView.MasterTableView.Columns.FindByUniqueNameSafe("company_name") Is Nothing Then
Me.gvCaseView.MasterTableView.GetColumn("company_name").Visible = True
End If
Me.gvCaseView.MasterTableView.GetColumn("case_id").Visible = True
Me.gvCaseView.MasterTableView.GetColumn("support_level").Visible = False
gvCaseView.MasterTableView.GridLines = GridLines.Both
gvCaseView.ExportSettings.ExportOnlyData = True
gvCaseView.ExportSettings.IgnorePaging = True
gvCaseView.ExportSettings.OpenInNewWindow = True
gvCaseView.MasterTableView.AllowFilteringByColumn = True
gvCaseView.MasterTableView.AllowSorting = False
gvCaseView.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None
gvCaseView.ExportSettings.FileName = System.Uri.EscapeDataString(Session("Title").ToString)
gvCaseView.MasterTableView.ExportToExcel()
Catch ex As Exception
ReportError("lnkExport_Click", ex)
Throw
End Try
End Sub
我已经尝试过这段代码,除了EDGE可以让任何人解决它之外,所有浏览器都能正常运行
导出到excel()函数完全无法解决问题
下载文件成功,iisue在打开文件时