Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 07-22-2018, 10:05 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 280
Default Inserting New Worksheet to CSV file from Delphi5 Application.

Dear Expert,

I am developing a program to export clientDataset to CSV file from Delphi5 application. I am loading StringList with clientdataset and saving file to CSV as below:

HTML Code:
procedure WriteDataSetToCSV(DataSet: TDataSet, FileName: String); var List: TStringList; S: String; I: Integer; 
begin List := TStringList.Create;
try
DataSet.First; 
while not DataSet.Eof do 
begin 
S := '';
 for I := 0 to DataSet.FieldCount - 1 do
 begin 
if S > '' then 
S := S + ','; 
S := S + '"' + DataSet.Fields[I].AsString + '"'; 
end; 
List.Add(S); 
DataSet.Next; 
end; 
finally 
List.SaveToFile(FileName); 
List.Free; 
end; 
end;
Now, I want to add new worksheet to same CSV file and add details from new ClientDataSet. How is that possible. I do not want to use Excel.

Thanks and regards,
__________________
Rmt
Reply With Quote
  #2  
Old 07-23-2018, 04:38 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 280
Default

Dear Expert,

Kindly come up with solution.

Thanks in advance.
__________________
Rmt
Reply With Quote
  #3  
Old 07-23-2018, 07:57 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,305
Default

It's not possible using csv.
Csv as a file is a delimited structure for only 1 dataset.

You could add more, but then Excel (or any other application that could interpret this) cannot handle it by default.
For Excel you could do some stuff with macro's to automatically interpret this, but I would lose the csv extension since it's basically your own format.
Reply With Quote
  #4  
Old 07-23-2018, 08:00 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,305
Default

Later versions of Excel are able to work with XML
https://technet.microsoft.com/en-us/...blogtales.aspx
Reply With Quote
  #5  
Old 07-23-2018, 09:03 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 280
Default

Dear Norrit,

Thanks for responding..
__________________
Rmt
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 08:52 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2018, vBulletin Solutions, Inc.