pero la verdad no se como podria empezar alguien me puede
orientar el como hacer

Escrito 28 abril 2010 - 07:52
Escrito 28 abril 2010 - 08:55
Escrito 28 abril 2010 - 08:57
function DataSetAHTML(DataSet: TDataSet): string; var intX: Integer; strLine: string; begin if not Dataset.Active then dataset.Open; DataSet.DisableControls; // Escribimos el encabezado del archivo Result := ''; result := Result + ''; for intX := 0 to dataset.FieldCount-1 do if DataSet.Fields[intX].Visible then Result := Result + ''; Result := Result + ''; // Recorremos cada Item del Dataset DataSet.First; while not DataSet.Eof do begin strLine := ''; for intX := 0 to DataSet.FieldCount-1 do if DataSet.Fields[intX].Visible then strLine := strLine +''; strLine := strLine + ''; Result := Result + strLine; DataSet.Next; end; // ok Result := Result + '' + '' + DataSet.Fields[intx].DisplayLabel + '' + '' + DataSet.Fields[intx].Text + ''; DataSet.EnableControls; end;
Escrito 28 abril 2010 - 02:38
Escrito 28 abril 2010 - 07:58
procedure DataSetToHTML(DataSet: TDataSet; Archivo: TFileName); var i: Integer; Contenido: TStringList; begin // Abrimos la Tabla if not Dataset.Active then dataset.Open; Contenido := TStringList.Create; try // Agregamos el Tag que define la tabla Contenido.Add('<table border="1">'); // Escribimos los Nombres de los Campos como Encabezado Contenido.Add('<tr>'); for i := 0 to DataSet.FieldCount -1 do Contenido.Add('<th BgColor="gray">'+DataSet.Fields[i].FieldName+'</th>'); Contenido.Add('</tr>'); // Recorremos todos los registros del DataSet y creamos las celdas DataSet.First; while not DataSet.Eof do begin Contenido.Add('<tr>'); for i := 0 to DataSet.FieldCount -1 do Contenido.Add('<td>'+DataSet.Fields[i].AsString+' </td>'); Contenido.Add('<tr>'); DataSet.Next; end; // Cerramos el Tag <table> Contenido.Add('</table>'); // Guardamos el Contenido en el archivo Contenido.SaveToFile(Archivo); finally // Liberamos el Objecto de Memoria Contenido.Free; end; end;
DataSetToHTML(Tabla, 'c:\test.html');
Escrito 30 abril 2010 - 03:04
procedure TForm1.Button1Click(Sender: TObject); Var LDmDatos : TDataModule2; intX : Integer; Contenido : string; LsMensaje : String; begin LDmDatos := TDataModule2.Create(self); LsMensaje := LDmDatos.ConVacAut('2010-04-15'); if LsMensaje = 'Nada' Then Try Memo1.Lines.Add( '<table border="1"><tr><td>ID_TICKET</td><td>Fecha Creacion</td><td>Creador</td><td>Estatus</td><td>Solicitadas</td><td>Fechas Solicitas</td><td>Dias Disponibles</td><td>Fecha limite</td></tr>'); //Recorremos cada item del Dataset while not LDmDatos.AdsDatos.Eof Do begin Contenido := '<tr>'; for intX :=0 to LDmDatos.AdsDatos.FieldCount-1 Do Contenido := Contenido + '<td>' + LDmDatos.AdsDatos.Fields[IntX].AsString + '</td>'; Contenido := Contenido + '</tr>'; LDmDatos.AdsDatos.Next; Memo1.Lines.Add(Contenido); end; Memo1.Lines.Add('</table>') Except showmessage('Ocurrio error al Generar el archivo Html'); end else showmessage(LsMensaje); end; end.
Escrito 26 marzo 2012 - 05:49
function DataSetToHTML(master,detail: TDataSet):string;//OD241 var i: Integer; Contenido: TStringList; Archivo: Integer; direccion:string; gen:TGenerador; begin // Abrimos la Tabla if not master.Active then master.Open; if not detail.Active then detail.Open; Contenido := TStringList.Create; try gen:=TGenerador.create; Archivo := gen.CreaArchivo(Direccion); //Direccion := 'http://'+UserSession.ptrServidor.strHost+':'+UserSession.ptrServidor.strPuertoHTTPConsulta+'/Files'; // Agregamos el Tag que define la tabla Contenido.Add('<TABLE BGCOLOR="white" WIDTH = "100%" CELLPADDING="2" CELLSPACING="0" BORDER ="1" BORDERCOLOR="black">'); Contenido.Add('<colgroup><col ALIGN="center"></colgroup>'); Contenido.Add('<TR><TD BGCOLOR="yellow" >REPORTE HISTORICO DE TURNO</TD></TR>'); master.First; while not master.eof do begin Contenido.Add('<TR><TD BGCOLOR="lime" ALIGN="left" STYLE="font-size:8pt;">INFORMACION DE TURNO</TD></TR>'); Contenido.Add('<TR><TD><TABLE WIDTH = "100%" HEIGHT="25" CELLPADDING="0" CELLSPACING="0" BORDER ="1" BORDERCOLOR="black" STYLE="font-size:8pt;" >'); Contenido.Add('<colgroup><col WIDTH = "10%" STYLE="background-color:yellow;text-align:left;"><col ></colgroup>'); Contenido.Add('<TR><TH>Fecha</TH><TD>'+master.Fields.FieldByNumber(1).asstring+'</TD></TR>'); Contenido.Add('<TR><TH>Oficina</TH><TD>'+master.Fields.FieldByNumber(2).asstring+'</TD></TR>'); Contenido.Add('<TR><TH>Sala</TH><TD>'+master.Fields.FieldByNumber(3).asstring+'</TD></TR>'); Contenido.Add('<TR><TH>Turno</TH><TD>'+master.Fields.FieldByNumber(4).asstring+'</TD></TR>'); Contenido.Add('</TABLE>'); if detail.RecordCount>0 then begin Contenido.Add('</TD></TR><TR><TD><TABLE WIDTH = "100%" HEIGHT="25" CELLPADDING="0" CELLSPACING="0" BORDER ="1" BORDERCOLOR="black" STYLE="font-size:8pt;">'); Contenido.Add('<colgroup><TD BGCOLOR="yellow" COLSPAN="'+inttostr(detail.FieldCount)+'" ALIGN="center">INFORMACION ADICIONAL</TD></colgroup>'); // Escribimos los Nombres de los Campos como Encabezado Contenido.Add('<TR BGCOLOR="lime">'); for i := 0 to detail.FieldCount -1 do Contenido.Add('<TH>'+detail.Fields[i].FieldName+'</TH>'); Contenido.Add('<TR>'); // Recorremos todos los registros del DataSet y creamos las celdas detail.First; while not detail.Eof do begin Contenido.Add('<TR>'); for i := 0 to detail.FieldCount -1 do Contenido.Add('<TD ALIGN="center">'+detail.Fields[i].AsString+' </TD>'); Contenido.Add('</TR>'); detail.Next; end; // Cerramos el Tag <table> Contenido.Add('</TABLE>'); end; Contenido.Add('<BR></TD></TR>'); master.next; end; // Guardamos el Contenido en el archivo FileWrite(Archivo, Contenido.text[1], Length(contenido.text)); FileClose(Archivo); Result:=Direccion; finally // Liberamos el Objecto de Memoria Contenido.Free; end; end; //esta funcion pertenece a una clase, pero igual creo se puede definir por aparte y a de funcionar function TGenerador.CreaArchivo(var Direccion: String): Integer; begin Direccion := GuidToString(uniGuidReporte)+'.HTML'; Result := FileCreate(GetCurrentDir+'\Files\Temp\'+Direccion); end; //Llamada despues de tener los datasets con los datos que se van a exportar if C_Maestro.recordcount>0 then begin strDireccion:=DataSetToHTML(C_Maestro,C_Detalle); if strDireccion<>'' then begin //si tienen un aplicacion intraweb esto hara que el reporte en html se haga visible en la maquina desde la cual se accede la aplicacion intraweb strDireccion := 'http://'+UserSession.ptrServidor.strHost+':'+UserSession.ptrServidor.strPuertoHTTPConsulta+'/Files/Temp/'+strDireccion; WebApplication.NewWindow(strDireccion, '', -1, -1,[woStatusBar, woScrollBars, woResizable], -1, -1); end end else WebApplication.ShowMessage('No existen datos historicos para generar el reporte');
<TABLE BGCOLOR="white" WIDTH = "100%" CELLPADDING="2" CELLSPACING="0" BORDER ="1" BORDERCOLOR="black">
<colgroup>
<col ALIGN="center">
</colgroup>
<TR><TD BGCOLOR="yellow" >REPORTE HISTORICO DE TURNO</TD></TR>
<TR><TD BGCOLOR="lime" ALIGN="left" STYLE="font-size:8pt;">INFORMACION DE TURNO</TD></TR>
<TR><TD><TABLE WIDTH = "100%" HEIGHT="25" CELLPADDING="0" CELLSPACING="0" BORDER ="1" BORDERCOLOR="black" STYLE="font-size:8pt;" >
<colgroup>
<col WIDTH = "10%" STYLE="background-color:yellow;text-align:left;">
<col >
</colgroup>
<TR><TH>Fecha</TH><TD>celda(1,1)</TD></TR>
<TR><TH>Oficina</TH><TD>Celda(1,1)</TD></TR>
<TR><TH>Sala</TH><TD> </TD></TR>
<TR><TH>Turno</TH><TD>celda(1,1)</TD></TR>
</TABLE>
</TD></TR>
<TR><TD><TABLE WIDTH = "100%" HEIGHT="25" CELLPADDING="0" CELLSPACING="0" BORDER ="1" BORDERCOLOR="black" STYLE="font-size:8pt;">
<colgroup>
<TD BGCOLOR="yellow" COLSPAN="3" ALIGN="center">INFORMACION ADICIONAL</TD>
</colgroup>
<TR BGCOLOR="lime"><TH>celda(1,1)</TH><TH>celda(1,2)</TH><TH>celda(1,3)</TH></TR>
<TR><TD ALIGN="left">celda(2,1)</TD><TD ALIGN="center">celda(2,2)</TD><TD ALIGN="left">celda(2,3)</TD></TR>
<TR><TD ALIGN="center">celda(2,1)</TD><TD ALIGN="left">celda(2,2)</TD><TD ALIGN="center">celda(2,3)</TD></TR>
<TR><TD ALIGN="left">celda(2,1)</TD><TD ALIGN="center">celda(2,2)</TD><TD ALIGN="left">celda(2,3)</TD></TR>
</TABLE>
</TD></TR>
<TR><TD><TABLE WIDTH = "100%" HEIGHT="25" CELLPADDING="0" CELLSPACING="0" BORDER ="1" BORDERCOLOR="black" STYLE="font-size:8pt;" >
<colgroup>
<col WIDTH = "10%" STYLE="background-color:yellow;text-align:left;">
<col >
</colgroup>
<TR><TH>Fecha</TH><TD>celda(1,1)</TD></TR>
<TR><TH>Oficina</TH><TD>Celda(1,1)</TD></TR>
<TR><TH>Sala</TH><TD> </TD></TR>
<TR><TH>Turno</TH><TD>celda(1,1)</TD></TR>
</TABLE>
</TD></TR>
<TR><TD><TABLE WIDTH = "100%" HEIGHT="25" CELLPADDING="0" CELLSPACING="0" BORDER ="1" BORDERCOLOR="black" STYLE="font-size:8pt;">
<colgroup>
<TD BGCOLOR="yellow" COLSPAN="3" ALIGN="center">INFORMACION ADICIONAL</TD>
</colgroup>
<TR BGCOLOR="lime"><TH>celda(1,1)</TH><TH>celda(1,2)</TH><TH>celda(1,3)</TH></TR>
<TR><TD ALIGN="left">celda(2,1)</TD><TD ALIGN="center">celda(2,2)</TD><TD ALIGN="left">celda(2,3)</TD></TR>
<TR><TD ALIGN="center">celda(2,1)</TD><TD ALIGN="left">celda(2,2)</TD><TD ALIGN="center">celda(2,3)</TD></TR>
<TR><TD ALIGN="left">celda(2,1)</TD><TD ALIGN="center">celda(2,2)</TD><TD ALIGN="left">celda(2,3)</TD></TR>
</TABLE>
</TD></TR>
</TABLE>