Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   Exportar dbase a otros formatos (https://www.clubdelphi.com/foros/showthread.php?t=64703)

Cristalero 15-04-2009 15:43:39

Exportar dbase a otros formatos
 
Muy buenas.

Tengo varias tablas dbf las cuales tengo que exportar su contenido a diferentes formatos. Alguna forma de exportarlos sin tener que recorrer dichas tablas?

Me gustaría exportalo a txt, xml y csv. Alguna idea?

Gracias!:confused:

delphi.com.ar 15-04-2009 15:56:49

Dos de esos tres formatos son soportados por mis componentes: FireSoft ExportSuite v.1

Saludos!

Cristalero 15-04-2009 15:59:53

Gracias Federico. Pero busco la forma de hacerlo con lo que trae delphi.

Gracias de todas formas. Si alguien me echa un cable de como hacerlo aunque solo sea txt? :confused:

Neftali [Germán.Estévez] 15-04-2009 16:11:18

Cita:

Empezado por Cristalero (Mensaje 345022)
Alguna forma de exportarlos sin tener que recorrer dichas tablas?

Sin recorrerlas difícil, por no decir imposible.
Otra cosa es buscar algun componente que te lo haga, si no quieres hacerlo tú, pero el componente igualmente deberá hacer el recorrido.

Cristalero 15-04-2009 16:17:54

Pense que habría algun procedimiento en delphi de este tipo.

Como siempre genial!! Gracias Neftalí.

Neftali [Germán.Estévez] 15-04-2009 17:27:38

Posiblemente el TXT (CSV) sea el más sencillo.
Basta con un WHILE + un FOR, uno para el recorrido y otro para los campos.

Algo así, aunque deberás afinarlo más...

Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
var
  i, j:Integer;
  fName:string;
  TS:TStrings;
  str:string;
  typ:TFieldType;
begin
  ADOTable1.Open;
  TS := TStringList.Create();
  fName := IncludeTrailingBackslash(ExtractFilePath(Application.ExeName)) + 'export.txt';

  // Recorrido
  while not ADOTable1.Eof do begin

    Str := '';
    for i := 0 to (ADOTable1.Fields.Count - 1) do begin

      // Tipo Correcto
      typ := ADOTable1.Fields[i].DataType;

      if (typ = ftString) or (typ = ftSmallint) or (typ = ftInteger) or
         (typ = ftWord) or (typ = ftBoolean) or (typ = ftFloat) or
         (typ = ftLargeInt) or (typ = ftDate) or (typ = ftDateTime) or
         (typ = ftCurrency) or (typ = ftWideString) then begin

        Str := Str + ADOTable1.Fields[i].AsString;
        if (i <> ADOTable1.Fields.Count) then begin
          Str := Str + ',';
        end;
      end;


    end;
    TS.Add(Str);

    ADOTable1.Next;
  end;

  Memo1.Lines.AddStrings(TS);
  TS.SaveToFile(fName);


  FreeAndNil(TS);
  ADOTable1.Close();
end;


La franja horaria es GMT +2. Ahora son las 21:28:16.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi