Jump to content


Photo

TNXGrid, SaveToExcel procedure


  • Please log in to reply
3 replies to this topic

#1 able

able
  • Members
  • 4 posts

Posted 04 June 2009 - 10:51 AM

Hi! I've wrote SaveToExcel procedure.

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;


#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 04 June 2009 - 09:43 PM

Hello Able,

Thank you for your code. I am sure that it will be helpful to other users.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 fastgear

fastgear
  • Members
  • 1 posts

Posted 09 December 2009 - 02:01 AM

Thank you Able, This will be useful for me!

#4 belajardelphi

belajardelphi
  • Members
  • 1 posts

Posted 17 December 2009 - 08:07 AM

Thanks ,Able




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users