Private Sub ibtnExcel_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibtnExcel.Click imgSearch.Visible = False imgClear.Visible = False imgAdd.Visible = False imgApply.Visible = False ibtnExcel.Visible = False ibtnVersion.Visible = False ibtnHelp.Visible = False _strstyleSheet = "" Dim i, j As Integer Dim xlApp As Excel.Application Dim xlSht As Excel.Worksheet Dim rng As Excel.Range xlApp = New Excel._ExcelApplication xlApp.DisplayAlerts = False xlApp.Workbooks.Add() xlSht = CType(xlApp.Sheets(1), Excel.Worksheet) xlSht.Name = "BDIS-Download" Dim dc As DataColumn Dim dr As DataRow For i = 0 To grdResult.Columns.Count - 1 xlSht.Cells(i + 1).value = grdResult.Columns(i) Next With xlSht rng = CType(.Columns(1), Excel.Range) rng.AutoFit() End With xlApp.ActiveWorkbook.Close(True, "C:\BDISTest.xls") xlApp.Quit() ReleaseComObject(rng) ReleaseComObject(xlSht) ReleaseComObject(xlApp) End Sub
xlSht.Cells(i + 1).Value2 = grdResult.Columns(i)
xlSht.Cells(i+1).Value
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)