Board index » delphi » Export Paradox Data to Text File

Export Paradox Data to Text File

Hi All,
There's a simple Paradox table and button on the form.
What procedure should be written to button OnClick event to create delimited
text file and to export all table data there?

Thank you.

 

Re:Export Paradox Data to Text File


Example:

procedure ExportCSV(const DataSet: TDataSet; const FileName: String);
var
  F: TextFile;
  i: Integer;
  S: String;
begin
  DataSet.Open;
  try
    AssignFile(F, FileName);
    ReWrite(F);
    try
      S := '';
      for i := 0 to DataSet.FieldCount - 1 do
      begin
        if DataSet.Fields[i].Visible then
        begin
          if i > 0 then
            S := S + ',';
          S := S + '"' + DataSet.Fields[i].DisplayLabel + '"';
        end;
      end;
      WriteLn(F, S);
      while not DataSet.EOF do
      begin
        S := '';
        for i := 0 to DataSet.FieldCount - 1 do
        begin
          if DataSet.Fields[i].Visible then
          begin
            if i > 0 then
              S := S + ',';
            S := S + '"' + DataSet.Fields[i].DisplayText + '"';
          end;
        end;
        WriteLn(F, S);
        DataSet.Next;
      end;
    finally
      CloseFile(F);
    end;
  finally
    DataSet.Close;
  end;
end;

"Dmitry Netchitailo" <dell...@usa.net> schreef in bericht
news:94gvft$8t8$1@fibber.robertsonblums.com.ua...

Quote
> Hi All,
> There's a simple Paradox table and button on the form.
> What procedure should be written to button OnClick event to create
delimited
> text file and to export all table data there?

> Thank you.

Other Threads