Foros del Web » Creando para Internet » HTML »

Crear con html un fichero doc

Estas en el tema de Crear con html un fichero doc en el foro de HTML en Foros del Web. Hola, No se si mi tema va en este hilo, supongo q si. Estoy realizando un proyecto para un trabajo, llevo bastante tiempo buscando una ...
  #1 (permalink)  
Antiguo 14/10/2008, 02:45
 
Fecha de Ingreso: junio-2007
Mensajes: 5
Antigüedad: 16 años, 9 meses
Puntos: 0
Crear con html un fichero doc

Hola,

No se si mi tema va en este hilo, supongo q si.

Estoy realizando un proyecto para un trabajo, llevo bastante tiempo buscando una solución pero no encuentro nada.

Resulta que tengo que generar con código html un word, que tenga cabecera y con información (de un dataset).


Es un formulario ASP.NET, con un botón html, que muestra un informe en formato word. Resulta que al lanzarlo, el texto de la cabecera aparece repetido en el cuerpo del documento word.

No se como quitarlo, si podeís ayudarme os lo agradecería.

Os pongo el código que utilizo:

-----------------------------------------------------------------------

protected override void Render(HtmlTextWriter writer)
{

string cuerpo = "<html xmlns:w=\"urn:schemas-microsoft-com:office:word\">";
cuerpo += "< xmlns:w=\"urn:schemas-microsoft-com:office:office\">";
cuerpo += "xmlns='http://www.w3.org/TR/REC-html40'>";
cuerpo += "xmlns:m='http://schemas.microsoft.com/office/2004/12/omml'";
cuerpo += "<meta http-equiv=Content-Type content='text/html;
charset=windows-1252'><meta name=ProgId
content=Word.Document><meta name=Generator content='Microsoft Word
11'><meta name=Originator content='Microsoft Word 11'>";
cuerpo += "<head>";
cuerpo += "<link rel=File-List href=\"filelist.xml\">";
cuerpo += "<title>Informe</title>";
cuerpo += "<!--[if gte mso 9]><xml>";
cuerpo += "<w:WordDocument>";
cuerpo += "<w:View>Print</w:View>";
cuerpo += "</w:WordDocument>";
cuerpo += "</xml><![endif]-->";
cuerpo += "</head><body >";
cuerpo += "<br/>";
cuerpo += "<strong><h1 align='center'>INFORME </h1></strong>";
cuerpo += "<br/>";

if (objetivo != string.Empty)
{
cuerpo += "<br/>";
cuerpo += "<p Align='left'><font face='arial' size='7px' ><b>";
cuerpo += "1. OBJETIVO DEL DOCUMENTO";
cuerpo += "</font> </b></p>";
cuerpo += "<p style='text-align :justify' ><font face='arial' size='6px' >";
cuerpo += objetivo + ".";
cuerpo += "</font> </p>";
cuerpo += "<br/>";
}

cuerpo += "<embed src='d:\\evidencias\\images.jpg'></embed>";
cuerpo += "</div>";
cuerpo += "<!--[if gte mso 9]><xml> <o:shapedefaults v:ext='edit'
spidmax='2049'/></xml><![endif]-->";
cuerpo += "<!--[if supportFields]><style> @page" + "{size:8.5in 11.0in;
mso-first-footer:ff1; mso-footer: f1; mso-header: h1; padding:24.0pt 24.0pt
24.0pt 24.0pt;" + " margin:0.75in 0.50in 0.75in 0.50in ; " + " mso-header-
margin:.5in; " + " mso-footer-margin:.5in; mso-paper-source:0;}" + "
div.Section1" + " {page:Section1;}" + "p.MsoFooter, li.MsoFooter,
div.MsoFooter{margin:0in; margin-bottom:.0001pt; mso-pagination:widow-
orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt;
font-family:'Arial';}" + "p.MsoHeader, li.MsoHeader, div.MsoHeader
{margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan;
tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:'Arial'}
</style>" + "<![endif]-->";

cuerpo += "<!--[if supportFields]><div class=Section1>";
cabecera = "<!--[if supportFields]> <span style='mso-element:field-begin'>
</span><![endif]-->";
cuerpo += "<div style='mso-element:header' id='h1'><p
class=MsoHeader>aaaaaaaa </p> </div>";
cuerpo += "</div>"+"<![endif]-->";
cuerpo += "</body></html>";

Response.ContentType = "application/msword";
Response.ContentEncoding = System.Text.Encoding.Default;
writer.Write(cuerpo);

}
-----------------------------------------------------------------------

Gracias por todo, cualquier duda q se os ocurra contarme

PD: Lo de "aaaaaaaa" es lo q se repite, cabecera y zona de detalle del word.
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 09:39.