Field-Map Scripting

4.6.1.2 OpenFile

OpenFile procedure


Prototype:

procedure OpenFile(const Filename :string);

Description:

Loads a file from disk.

Syntax:

xls.OpenFile(FileName);  


Part

Description


FileName

Variable declared as string


xls

Variable declared as an instance of the TExcelWrapper class

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.