unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComObj;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Excel, WrkS, WrkB : OLEVariant;
XlFileFormat : Variant;
ConsecutiveDelimiter : Variant;
Tab : Variant;
Comma : Variant;
begin
Excel := createOleObject('Excel.Application');
Excel.DisplayAlerts:=false;
ConsecutiveDelimiter := True;
Comma := True;
Excel.Workbooks.Opentext('D:\TestFile_Comma.txt',
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
ConsecutiveDelimiter,
EmptyParam,
EmptyParam,
Comma,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam);
XlFileFormat := 51;
Excel.WorkBooks[1].WorkSheets[1].Name := 'CSV';
WrkB := Excel.WorkBooks[1].WorkSheets['CSV'];
WrkB.SaveAs('D:\ExcelFile.xlsx',XlFileFormat);
Excel.quit;
end;
end.