IPrxReportExporter.FinishBatchCommand

Syntax

FinishBatchCommand;

Description

The FinishBatchCommand method finishes batch export of data to a file. This method is used together with the StartBatchCommand method.

Comments

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";
    
// Determining 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 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 opens. Select regular reports to be exported. Then the objects are exported to the file C:\BatchFilePrx.xls. Export progress reports are displayed in the Memo1 component.

See also:

IPrxReportExporter