Foros del Web » Programación para mayores de 30 ;) » .NET »

Exportar datos a Word - asp.net

Estas en el tema de Exportar datos a Word - asp.net en el foro de .NET en Foros del Web. Hola, estoy haciendo una web en asp.net, en la que una de las opciones es exportar a word, tengo creado una plantilla de word con ...
  #1 (permalink)  
Antiguo 07/10/2009, 02:10
 
Fecha de Ingreso: enero-2006
Mensajes: 263
Antigüedad: 18 años, 3 meses
Puntos: 1
Exportar datos a Word - asp.net

Hola, estoy haciendo una web en asp.net, en la que una de las opciones es exportar a word, tengo creado una plantilla de word con marcadores, pero lo que no es que codigo debo poner para exportar los datos.

Gracias y perdon por las molestias
  #2 (permalink)  
Antiguo 07/10/2009, 04:28
 
Fecha de Ingreso: octubre-2009
Mensajes: 6
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Exportar datos a Word - asp.net

yo te pongo el codigo que tengo yo echo para excel que debera ser parecido a uno de word.
Yo lo que tengo es una imagen de excel y cuando la pulso me exporta los datos a excel.
Aqui te pongo el codigo del boton

Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
Try
Dim i, j As Integer
Dim ls_linea, ls_color1, ls_color2, ls_color As String
Dim li_color As Integer = 1
'Dim ofile As File
'Dim oDir As DirectoryInfo
'Dim clase_envio As New cEnvio_Correo(Server.MapPath("~"))
'SINO EXISTE LA CARPETA temporal del usuario ENTONCES SE CREA
'oDir = New DirectoryInfo(Server.MapPath("~") & ConfigurationManager.AppSettings("PATH_DOCUMENTOS" ) & Session("usuario") & "\TEMPORAL\")

'If ofile.Exists(Server.MapPath("~") & ConfigurationManager.AppSettings("PATH_DOCUMENTOS" ) & Session("usuario") & "\TEMPORAL\objetivos.xls") Then
' ofile.Delete(Server.MapPath("~") & ConfigurationManager.AppSettings("PATH_DOCUMENTOS" ) & Session("usuario") & "\TEMPORAL\objetivos.xls")
' End If


ls_color1 = "LightSteelBlue"
ls_color2 = "Lavender"
Response.Clear()

Response.AddHeader("Content-Disposition", "attachment; filename=objetivo.xls")

Response.ContentType = "application/vnd.ms-excel"

'Response.Write("<table cellspacing='0' rules='all' border='1' id='GRID_SQL' style='background-color:#666696;border-color:White;border-collapse:collapse;'>")
Response.Write("<table border='0' id='GRID_SQL'>")
' Response.Write("<tr style='color:MidnightBlue;background-color:CornflowerBlue;border-color:White;font-weight:normal;'>")
Response.Write("<tr>")
Response.Write("<td style='background-color: #6666ff; font-weight: bold; font-size: 14px;text-align: center; vertical-align: middle; width: 100px; border-top-style: solid; border-right-style: solid; border-left-style: solid; border-bottom-style: solid;'>Código Referencia</td><td style='background-color: #6666ff; font-weight: bold; font-size: 14px;text-align: center; vertical-align: middle; width: 220px; border-top-style: solid; border-right-style: solid; border-left-style: solid; border-bottom-style: solid;'>Desc. Cliente</td><td style='background-color: #6666ff; font-weight: bold; font-size: 14px;text-align: center; vertical-align: middle; width: 100px; border-top-style: solid; border-right-style: solid; border-left-style: solid; border-bottom-style: solid;'>Desc. Provincia</td><td style='background-color: #6666ff; font-weight: bold; font-size: 14px;text-align: center; vertical-align: middle; width: 90px; border-top-style: solid; border-right-style: solid; border-left-style: solid; border-bottom-style: solid;'>Fecha Creación</td><td style='background-color: #6666ff; font-weight: bold; font-size: 14px;text-align: center; vertical-align: middle; width: 160px; border-top-style: solid; border-right-style: solid; border-left-style: solid; border-bottom-style: solid;'>Estado</td><td style='background-color: #6666ff; font-weight: bold; font-size: 14px;text-align: center; vertical-align: middle; width: 160px; border-top-style: solid; border-right-style: solid; border-left-style: solid; border-bottom-style: solid;'>Solicitante</td><td style='background-color: #6666ff; font-weight: bold; font-size: 14px;text-align: center; vertical-align: middle; width: 110px; border-top-style: solid; border-right-style: solid; border-left-style: solid; border-bottom-style: solid;'>Objetivo Ventas</td><td style='background-color: #6666ff; font-weight: bold; font-size: 14px;text-align: center; vertical-align: middle; width: 110px; border-top-style: solid; border-right-style: solid; border-left-style: solid; border-bottom-style: solid;'>Rappel Generado</td>")
Response.Write("</tr>")




For i = 0 To 9
If li_color = 1 Then
ls_color = ls_color1
li_color = 2
Else
ls_color = ls_color2
li_color = 1
End If
Response.Write(" <tr>")
For j = 0 To 9
'CENTRAMOS LA COLUMNA código de contratro, PROVINCIA Y FECHA
If j = 0 Or j = 2 Or j = 3 Then
Response.Write(" <td style='background-color:" & ls_color & ";text-align: center;vertical-align: middle;border-right-style: solid; border-left-style: solid; border-bottom-style: solid;'>aa</td>")
Else

Response.Write(" <td style='background-color:" & ls_color & "; vertical-align: middle;border-right-style: solid; border-left-style: solid; border-bottom-style: solid;'>aa</td>")
End If
Next j
Response.Write(" </tr>")
Next i
Response.Write(" <tr >")
For j = 0 To 9
Response.Write(" <td style='width: 100px; border-left-style: none; border-bottom-style: none;'></td>")
Next j
Response.Write(" <td style='FONT-WEIGHT: bold; FONT-SIZE: 15px; BACKGROUND-COLOR: #6666ff; TEXT-ALIGN: right;border-right-style: solid; border-left-style: solid; border-bottom-style: solid;'>TOTAL</td>")
Response.Write(" <td style='FONT-WEIGHT: bold; FONT-SIZE: 15px; BACKGROUND-COLOR: #6666ff; TEXT-ALIGN: right; border-right-style: solid; border-left-style: solid; border-bottom-style: solid;'>xx</td>")
Response.Write(" <td style='FONT-WEIGHT: bold; FONT-SIZE: 15px; BACKGROUND-COLOR: #6666ff; TEXT-ALIGN: right; border-right-style: solid; border-left-style: solid; border-bottom-style: solid;'>yy</td>")
Response.Write(" </tr>")
Response.Write("</table>")

Response.End()
Catch ex As Exception

End Try
End Sub
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:23.