"open save cancel" prompt when exporting excel sheet using vb.net

Posted by Krishnasamy2008 under ASP.NET on 8/19/2011 | Points: 10 | Views : 2945 | Status : [Member] | Replies : 0
Hi Friends,

I want to do programmatically "open save cancel" prompt while exporting to excel sheet using asp.net with vb.net or c# .Can anyone share me your idea?I don't want to do gridview to export options.

Code:
-----------
Private Sub ExportToExcel(ByVal dt As DataTable, ByVal templateName As String)

Try
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim i As Integer = 2

xlWorkBook = New Excel.Application().Workbooks.Add(Missing.Value)
xlWorkSheet = xlWorkBook.ActiveSheet

'xlWorkSheet.Cells(1, 1) = TEMPLATECOL_UPLOADID
xlWorkSheet.Cells(1, 1) = TEMPLATECOL_FORMFIELD
xlWorkSheet.Cells(1, 2) = TEMPLATECOL_TEMPLATE
xlWorkSheet.Range("$A1:$O1").Font.Bold = True

'Outputting the data
For Each dr As DataRow In dt.Rows
'xlWorkSheet.Cells(i, 1) = dr("UploadID").ToString()
xlWorkSheet.Cells(i, 1) = dr("Form Field").ToString()
xlWorkSheet.Cells(i, 2) = dr("Template").ToString()
'Move to the next row
i = i + 1
Next

'Auto fit the columns
xlWorkSheet.Columns.AutoFit()

'Make the excel sheet visible only after writing all data
xlWorkBook.Application.Visible = True

Catch ex As Exception
Throw ex
End Try
End Sub

Thanks
Krishna.K




Responses

(No response found.)

Login to post response