Exporting Workbook to Various Formats

A workbook can be exported to the following formats: MHT, HTML, PDF, XLS, XLSX, RTF, EMF, PPTX.

Executing the example requires that the repository contains a workbook with the OBJ123 identifier which is to be exported.

Add links to the following system assemblies:

Fore Example

Sub UserProc;
Var
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    Exp: IEaxAnalyzer;
    Export: IExAnalyzerExporter;
Begin
    MB := MetabaseClass.Active;
    //Open a workbook to edit
    MObj := MB.ItemById("OBJ123").Edit;
    Exp := MObj As IEaxAnalyzer;
    Export := New ExAnalyzerExporter.Create;
    Export.ExAnalyzer := Exp;
    //Export the workbook to XLS format
    Export.ExportToFile("C:\GDP ratio.xls""XLS");
End Sub UserProc;

After executing the example the workbook is saved on the local disk in XLS format.

Fore.NET Example

The defined procedure is the Main entry point in the Program module of the .NET assembly. The Express, Metabase system assemblies must be imported to this module from the Prognoz.Platform.Interop system assembly.

Public Shared Sub Main(Params: StartParams);

Var
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    Exp: IEaxAnalyzer;
    Export: IExAnalyzerExporter;
Begin
    MB := Params.Metabase;
    //Open  workbook to edit
    MObj := MB.ItemById["OBJ123"].Edit();
    Exp := MObj As IEaxAnalyzer;
    Export := New ExAnalyzerExporter.Create();
    Export.ExAnalyzer := Exp As EaxAnalyzer;
    //Export the workbook to XLS format
    Export.ExportToFile("C:\GDP ratio.xls""XLS");
End Sub;

The result of example execution matches with that of the Fore example.

See also:

Examples