IPrxReportExporter.StartBatchCommand

Syntax

StartBatchCommand(FileName: String; FormatTag: String);

Parameters

FileName - name of the file, to which the data is to be exported.

FormatTag - format of the file, to which the data is to be exported. The following formats can be used:

Description

The StartBatchCommand method starts batch export of data to a file with the specified format.

Comments

After calling this method, each time the ExportToFile method is called, the report specified in the Report property is exported. Data is exported to a file with parameters specified in the StartBatchCommand method. Call the FinishBatchCommand method to finish batch data export. Thus, several reports may be exported to a single file.

NOTE. Multiple reports can be exported only when all the sheets have different names.

Example

Executing the example requires a form, a button named Button1 on this form, the MetabaseOpenDialog component named MetabaseOpenDialog1 and the Memo component named Memo1. The example is to be executed after clicking the Button1 button.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    Filter: IMetabaseDialogClassFilter;
    Objects: IMetabaseObjectDescriptorList;
    List: IStringList;
    Exp: PrxReportExporter;
    i, Count: integer;
    id: String;
Begin
    MetabaseOpenDialog1.MultiSelect := 
True;
    
// Create a filter for dialog box of opening repository object.
    Filter := New MetabaseDialogClassFilter.Create;
    Filter.Description := 
"Regular reports";
    
// Determine type of objects to be displayed in dialog box when using this filter: regular report.
    Filter.ObjectClass := MetabaseObjectClass.KE_CLASS_PROCEDURALREPORT;
    MetabaseOpenDialog1.Filters.AddFilter(Filter);
    
If MetabaseOpenDialog1.Execute(Self) Then
        
// These operations are executed if the user has selected one or several regular reports.
        Objects := MetabaseOpenDialog1.Objects;
        Count := Objects.Count;
        List := Memo1.Lines;
        List.Add(
"Number of reports to be exported:" + Count.ToString);
        
// Start batch export of selected  reports.
        Exp := New PrxReportExporter.Create;
        Exp.StartBatchCommand(
"C:\BatchFilePrx.xls""XLS");
        
For i := 0 To Count - 1 Do
            id := Objects.Item(i).Id;
            Exp.Report := MetabaseClass.Active.ItemById(id).Bind 
As IPrxReport;
            Exp.ExportToFile(
"""XLS");
            List.Add(
"Report '" + Objects.Item(i).Name + "' Exported");
        
End For;
        
// Finish batch export of selected reports.
        Exp.FinishBatchCommand;
        List.Add(
"Export complete");
    
End If;
End Sub Button1OnClick;

After executing the example a dialog box for opening a repository object is opens. Select regular reports to be exported. Then the objects are exported into the file C:\BatchFilePrx.xls. Export progress reports are displayed in the Memo1 component.

See also:

IPrxReportExporter