Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/10/2009, 04:28
wondelzamora
 
Fecha de Ingreso: octubre-2009
Mensajes: 6
Antigüedad: 15 años, 4 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