//TXLSReadWriteII2 version Export Excel file:procedureTform1.n1click (sender:tobject);varI:integer; Asavedialog:tsavedialog; Afilename, astamptime:ansistring; Axlsobj:txlsreadwriteii2; P:pdatarec;beginAsavedialog:= Tsavedialog.Create(self); TryAsavedialog.initialdir:= Extractfilepath (Paramstr (0)); Asavedialog.defaultext:='xls'; Asavedialog.filter:='Excel File (*.xls) |*.xls| All Files (*. *) |*.*'; Astamptime:= FormatDateTime ('Yyyymmddhhnnss', now); Asavedialog.filename:=Astamptime; if notAsavedialog.execute ThenExit; Afilename:=Asavedialog.filename; ifAfilename ="' ThenExit; finallyAsavedialog.free; End; Axlsobj:= TXLSReadWriteII2.Create(Nil); Tryaxlsobj.sheets[0]. aswidestring[0,0] :='ID'; axlsobj.sheets[0]. aswidestring[1,0] :='Table'; axlsobj.sheets[0]. aswidestring[2,0] :='Kind'; axlsobj.sheets[0]. aswidestring[3,0] :='rows'; axlsobj.sheets[0]. aswidestring[4,0] :=' Times'; axlsobj.sheets[0]. aswidestring[5,0] :='desc'; fori:=1 toFdatahash.count-1 Do beginP:=Fdatahash[i]; axlsobj.sheets[0]. aswidestring[0, I]: = Format ('%d', [p.id]); axlsobj.sheets[0]. aswidestring[1, I]: =p.table; axlsobj.sheets[0]. aswidestring[2, I]: =P.kind; axlsobj.sheets[0]. aswidestring[3, I]: = Format ('%d', [p.rows]); axlsobj.sheets[0]. aswidestring[4, I]: = Format ('%d', [p.times]); axlsobj.sheets[0]. aswidestring[5, I]: =P.desc; End; Axlsobj.filename:=Afilename; Axlsobj.write; ShowMessage (Format ('Export File'+# -#Ten+'%s'+# -#Ten+'Success!', [afilename])); finallyAxlsobj.free; End;End;
TXLSReadWriteII2 version export Excel file: