Export data to an Excel note in Delphi (it is not necessary to install an Excel file but it is difficult to save it)

Source: Internet
Author: User
Procedure txggl_sjrz_exefrm.filesaveasmnuclick (Sender: tobject );
VaR
I: integer;
STR: string;
Strlist: tstringlist;
Issave: Boolean;
Title: string;
Begin
Try
If savedialog1.execute then
Begin
Issave: = true;
If fileexists (savedialog1.filename) then
If IDNO = MessageBox (handle, 'the file already exists. Are you sure you want to save it? ',' Hint ', mb_iconstop + mb_yesno) then
Begin
Issave: = false;
End;
If issave then
Begin
Strlist: = tstringlist. Create;
With rsrzdbgrid do
Begin
Title: = '';
For I: = 0 to columns. Count-1 do
Begin
Title: = title + columns [I]. Title. Caption + #9;
End;
Strlist. Add (title );
End;
With dm1.adoquery1 do
Begin
First;
While not EOF do
Begin
STR: = '';
For I: = 0 to FieldCount-1 do
STR: = STR + fields [I]. asstring + #9;
Strlist. Add (STR );
Next;
End;
Strlist. savetofile (savedialog1.filename );
MessageBox (handle, 'Data is successfully saved. ', 'hs', mb_ OK + mb_iconinformation );
End;
End;
End;
Finally
Freeandnil (strlist );
End;

End;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.