Showing posts with label Save Excel. Show all posts
Showing posts with label Save Excel. Show all posts

Friday, 22 February 2013

How to Save Excel File Automatically


IF NOT CREATE(XlApp) THEN
  ERROR('Excel Not Found.');
xlBook := xlApp.Workbooks.Add(-4167);
xlSheet:= xlApp.ActiveSheet;
xlSheet.Name := 'Mohana'; //Sheet name

xlSheet.Range('A1').Value := 'Mohana';
xlSheet.Range('B1').Value := 'MVP-Microsoft Dynamics NAV';
xlSheet.Columns.AutoFit;
xlApp.Visible := TRUE;
xlBook.SaveAs('C:\Test\Mohana.xlsx'); // To save the excel file
xlBook.Close; //To Close the Excel