CODE
procedure TMForm.SaveToExcel(RGrid: TNxGrid);
var
XLApp: Variant;
i, n: integer;
begin
XLApp:= CreateOleObject('Excel.Application');
XLApp.DisplayAlerts := false;
XLApp.Workbooks.Add;
XLApp.Visible:=true;
XLApp.Workbooks[1].WorkSheets[1].Name:='NXGrid Export';
XLApp.WorkBooks[1].WorkSheets[1].Rows[1].Font.Bold := true;
for i:=0 to RGrid.Columns.Count-1 do
XLApp.WorkBooks[1].WorkSheets[1].Cells[1,i+1] := RGrid.Columns[i].Header.Caption;
for i:=0 to RGrid.RowCount-1 do
for n:=0 to RGrid.Columns.Count-1 do
XLApp.WorkBooks[1].WorkSheets[1].Cells[i+2,n+1] := RGrid.Cell[n,i].AsString;
end;
var
XLApp: Variant;
i, n: integer;
begin
XLApp:= CreateOleObject('Excel.Application');
XLApp.DisplayAlerts := false;
XLApp.Workbooks.Add;
XLApp.Visible:=true;
XLApp.Workbooks[1].WorkSheets[1].Name:='NXGrid Export';
XLApp.WorkBooks[1].WorkSheets[1].Rows[1].Font.Bold := true;
for i:=0 to RGrid.Columns.Count-1 do
XLApp.WorkBooks[1].WorkSheets[1].Cells[1,i+1] := RGrid.Columns[i].Header.Caption;
for i:=0 to RGrid.RowCount-1 do
for n:=0 to RGrid.Columns.Count-1 do
XLApp.WorkBooks[1].WorkSheets[1].Cells[i+2,n+1] := RGrid.Cell[n,i].AsString;
end;