Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/10/2003, 14:42
Avatar de RootK
RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 23 años, 1 mes
Puntos: 50
Por cierto.. les voy a escribir un ejemplo de como lo hago con VB net y VBscript para crear el objeto.

1.- Creo una webapplication (es importante saber el nombre para identificarlo con a través de las referencias que se harán, tambien coloco un grid para mostrar los resultados.) y pongo el siguiente código en el evento load de la página:

Cita:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

If Not IsPostBack Then
Dim objConn As New SqlConnection(ConfigurationSettings.AppSettings("N orthWind"))
objConn.Open()

Dim strSQL As String
Dim objDataset As New DataSet
Dim objAdapter As New SqlDataAdapter

strSQL = "Select * from customers where country='USA'"
objAdapter.SelectCommand = New SqlCommand(strSQL, objConn)
' Fill the dataset.
objAdapter.Fill(objDataset)
' Creato una nueva vista
Dim oView As New DataView(objDataset.Tables(0))
' Set up the data grid and bind the data.
DataGrid1.DataSource = oView
DataGrid1.DataBind()

' Verifico si la pagina es mostrada en excel
If Request.QueryString("bExcel") = "1" Then
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False

Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)

' Obtengo el HTML del control DataGrid1.RenderControl(hw)
' Escribo el HTML que regreso del control Response.Write(tw.ToString())
Response.End()
End If

End If
2.- Creo un archivo llamado frameset.htm(será el principal) y escribo lo siguiente:

<html>
<frameset rows="10%,90%">
<frame noresize="0" scrolling="no" name="top" src="top.htm">
<frame noresize="0" scrolling="yes" name="bottom" src="plantilla.aspx">
</frameset>
</html>


3.- Genero un archivo llamado Top.htm y pongo lo siguiente:

Cita:
<html>
<script language="vbscript">
Sub Button1_onclick

Select Case Select1.selectedIndex

Case 0 ' Tipo MIME (En una nueva ventana)
window.open("plantilla.aspx?bExcel=1")

Case 1 ' TipoMIME (En el frame)
window.parent.frames("bottom").navigate "plantilla.aspx?bExcel=1"
End Select
End Sub
</script>
<body>
Exportar a excel usando:
<SELECT id="Select1" size="1" name="Select1">
<OPTION value="1">Tipo MIME (En una nueva ventana)</OPTION>
<OPTION value="2">TipoMIME (En el frame)</OPTION>
</SELECT>
<INPUT id="Button1" type="button" value="Go!" name="Button1">
</body>
</html>
Solo es cosa de hacer copy and paste del código ya que lo probé y funciona sin problemas.

P.D.- Lo hice con la base de datos Northwind del sql server.

Espero que les sirva.

Saludos
__________________
Nadie roba nada ya que en la vida todo se paga . . .

Exentrit - Soluciones SharePoint & Net