looking 4 software that convert TDBGrid 2 Ascii

hellow im looking 4 a software that convert TDBGrid to ascii file. i need to define the fields b4 the converting.
i need to change the formats of the fields b4 the converting.
for example date data  dd/mm/yyyy will  set  as yyyymmdd in the ascii file
croudoAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Melih SARICAConnect With a Mentor IT ManagerCommented:
Its not important .. U can either format ur fields as they r in the DBgrid or not..

U can format ur fields at runtime how ever u want.. ıt depends on u ..

If ur fields ll ave the same format everytime u want to export..

Cretae a table that ll collect every field in ur Database and their Masks..
or Just add the fields that ll ave special Format settings..

During the export process check this table if it has special Format option, and apply this format to the report builder...
or Use the original format and apply this to ur report field..

Or.. At runtime with the report builders runtime Builder u can build ur report with selected fields and selected firlds mask/format ..

Thats it..

0
 
Ivanov_GCommented:

   Take a look at this - it is export to Excel, you can take the same idea to export to text dilimited file.

   http://www.swissdelphicenter.ch/en/showcode.php?id=1427
0
 
croudoAuthor Commented:
i know that site but he not let me change the format of the field b4 export :(
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
mokuleCommented:
Do it Yourself

procedure TForm1.Export;
var
  i: integer;
begin
  DBGrid1.DataSource.DataSet.First;
  DBGrid1.DataSource.DataSet.DisableControls;
  while not DBGrid1.DataSource.DataSet.Eof do
    begin
    for i := 0 to DBGrid1.Columns[i].Count-1
      begin
      if DBGrid1.Columns[i].FieldName = 'something' then
        begin
        // do desired format and export
        end;
      if DBGrid1.Columns[i].FieldName = 'something else' then
        begin
        // do desired format and export
        end;
      end;
    DBGrid1.DataSource.DataSet.Next;
    end;
  DBGrid1.DataSource.DataSet.EnableControls;
end;
0
 
croudoAuthor Commented:
thankss but i need some thing modular for users.
0
 
augustoseCommented:
try with this code, call me if not work


unit ugridtotext;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DB, Grids, DBGrids, IBCustomDataSet, IBDatabase;

type
  TForm1 = class(TForm)
    IBDatabase1: TIBDatabase;
    IBTransaction1: TIBTransaction;
    DataSet1: TIBDataSet;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    procedure Exportgrid;

  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Exportgrid;
var
  i: integer;
  F: TextFile;
  ok : boolean;
begin
  ok := False;
  AssignFile(F, ExtractFilePath(Application.ExeName) + 'Dbgrid.csv');   { File selected in dialog box }
  try
    Append(F);
    ok := True;
  except
    try
      Rewrite(F);
      ok := True;
    except
    end;
  end;

  DBGrid1.DataSource.DataSet.First;
  DBGrid1.DataSource.DataSet.DisableControls;
  while not DBGrid1.DataSource.DataSet.Eof do
  begin
    for i := 0 to DBGrid1.DataSource.DataSet.fields.Count-1 do
    begin
      Write(f,DBGrid1.DataSource.DataSet.Fields[i].AsString);
      Write(F, ',' );
    end;
    WriteLn(F, '' );
    DBGrid1.DataSource.DataSet.Next;
  end;

  DBGrid1.DataSource.DataSet.EnableControls;
  CloseFile(F);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Exportgrid;
end;


end.



0
 
calinutzCommented:
listening
0
 
croudoAuthor Commented:
hi augustose its works.
but i need some thing that let me set the format of each field.
some field need to be cut from x position to y position and some need to be in ansi, dont u know some thing that all ready working?.
thankss 4 the care.
croudo assaf
0
 
Melih SARICAIT ManagerCommented:
Why dont u use a Report for example Qreport ... and try to export it in a text file.. u can desing all ur field masks...


Its easy fast ...

0
 
croudoAuthor Commented:
hi non zero
how can i export qrp format to text format and how can i change desing all my masks field on fly???
that a lot croudo assaf.
0
 
Melih SARICAIT ManagerCommented:
U get data in to ur DBGrid from a dataset rite ?

Create a form, add a report  and a exporter like Txt exporter in desing time..

In Run time..
 When u want to export ur data,
  1. Assign ur DbGrids dataset as ur report data set.
  2. Add fields that ur using in ur Dbgrid to the report
  3. Set mask properties of the fields same as ur dbgrid.
  4. Prepare report ..
  5. Export ur data
0
 
croudoAuthor Commented:
there r many components of what u say but it not fit to me.
i dont want to export the field as they show in the dbGrid i want to format them in my self.
thankss croudo  assaf.
0
 
augustoseCommented:
try using
free repport
that is the way
0
 
croudoAuthor Commented:
what is free report??? :(
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.