Field-Map Scripting

4.6.1.4 CloseAndSave

CloseAndSave procedure


Prototype:

procedure CloseAndSave (const OpenExcel:boolean);

Description:

Saves the file to disk and alternatively opens it in Excel

Syntax:

xls.CloseAndSave(OpenExcel);


Part

Description


xls

Variable declared as an instance of the TExcelWrapper class


OpenExcel

Variable declared as boolean (True=open, False=do not open)

Return value:

none


See also:

OpenFile, FileName, CloseAndSave, OpenInExcel, Complex example


Example:

Var
  xls :TExcelWrapper;

Begin
  {data preparation}
  //data querying etc...

  {document preparation}  
  xls:=TExcelWrapper.Create;   
  try
    xls.CreateFile(ProjectDir+'ExcelTasks\MyExcelTask');
    
    {managing worksheets}
    {managing formats}
    {setting cell values}
    {etc....}
    
    try 
      xls.CloseAndSave(true);    // save and open file in Excel
      
      {or
      
      xls.ShowExcelPreview('OpenInExcel=0;SaveToExcelFile=0');      // show thumbnail preview
      
       or
      
      xls.CloseAndSave(false);   // save file in Excel
      xls.OpenInExcel(FileName); // open file in Excel
      
      }
    except
      ShowError('Error on saving file.');
    end;     
  finally
    xls.Free;
  end;           
End.