I don't know if this would help. I wasn't sure if you needed a browser-
based or desktop solutiobn. On an .aspx web page I use it to transfer
data from a datagrid to a new Excel sheet. A dialog box pops up asking
if I want to open or save the new excel sheet and promps me for the
name (txtFileName) I would like to call the excel sheet. I type in the
name into the texbox called: txtFileName.

I hope this helps. I'd be interested in seeing any other developers'
more creative uses for exporting to Excel as mine are rather limited.
It would be great to know if it's possible to select only certain
"cells" or a range of "cells" from datagrids, etc. to transfer only
selected data to Excel

<script>

Sub doExport(Source as Object, E as EventArgs)
RenderGridToExcelFormat(dgWidgets,txtFileName.text)
End Sub

'Exports dgWidgets to a new Excel File. User is to type in the name
of
'the file to be created without the .xls extension.

Sub RenderGridToExcelFormat(grid As DataGrid, saveAsFile As
String)
       HttpContext.Current.Response.Clear()
       HttpContext.Current.Response.ContentType = "application/vnd.ms-
excel"
       HttpContext.Current.Response.AddHeader("content-disposition",
"attachment;filename=" & saveAsFile & ".xls")
       HttpContext.Current.Response.Charset = ""
       grid.EnableViewState = False
       Dim tw As New System.IO.StringWriter()
       Dim hw As New System.Web.UI.HtmlTextWriter(tw)
       grid.RenderControl(hw)
       HttpContext.Current.Response.Write(tw.ToString())
       HttpContext.Current.Response.End()
End Sub

</script>

On Sep 24, 3:38 am, yspin <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have an already made XL workbook.
>
> I would like to write a small VB program that wil allow users to make
> a selection and that a specifc workbook will be created according to
> these selections.
> I know how to do it with a user form in VB macro but i would like to
> have a .NET software fot the user interface.
>
> Thanks,
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web 
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---

Reply via email to