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

3 comments:

  1. Hi Sir, similarly can i save to CSV file format?

    ReplyDelete
  2. Please help me for knowing these variable

    ReplyDelete