Fórum Exportar informações de um StringGrid para .xml #289734
27/07/2005
0
:!:
Tenho um StringGrid com algumas informações e preciso exporta-las para um arquivo .xml, tem como fazer isso :?:
Desde já agradeço pela atenção de todos.
Semchance
Curtir tópico
+ 0Posts
27/07/2005
Semchance
sobe
Gostei + 0
28/07/2005
Keidysakamoto
ClientDataSet1.SaveToFile(´arquivo.xml´,dfXML);
Gostei + 0
28/07/2005
Semchance
Obs: Uso Delphi 5.
Gostei + 0
29/07/2005
Semchance
Obs : Delphi 5.
Gostei + 0
29/07/2005
Semchance
Basta colocar tres botões na tela e o codigo referente a cada botão
procedure TForm1.Button1Click(Sender: TObject);
begin
//Rotina para criar o ClientDataSet
with ClientDataSet1 do
begin
with FieldDefs.AddFieldDef do
begin
DataType := ftInteger;
Name := ´ID´;
end;
with FieldDefs.AddFieldDef do
begin
DataType := ftString;
Size := 20;
Name := ´Nome´;
end;
with IndexDefs.AddIndexDef do
begin
Fields := ´Id´;
Name := ´IntIndex´;
end;
CreateDataSet;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
i :integer;
begin
//Rotina para Incluir dados no ClientDataSet
i:= 0;
While i < 3 do
begin
With ClientDataSet1 do
begin
Append;
FieldByName(´id´).AsInteger := i;
FieldByName(´Nome´).AsString := ´Mané da Silva´;
Post;
end;
inc(i);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
//Rotina para Criar o .Xml
ClientDataSet1.SaveToFile(´C:\ClientData.xml´,DfXml);
end;
O ClientDataset, alem de funcionar igual tabela...ele gera o arquivo.xml.
Valeu....
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)