IDmReportDataSource.CopyToTabSheet

Fore Syntax

CopyToTabSheet: ITabSheet;

Fore.NET Syntax

CopyToTabSheet(): Prognoz.Platform.Interop.Tab.TabSheet;

Description

The CopyToTabSheet method copies data to a separate table.

Comments

The method can be used to save analysis results on a separate sheet of regular report.

Fore Example

Executing the example requires that the repository contains a regular report with the REG_DATA_DM identifier. The first sheet of the report must contain numeric values in the range A0:D36. Part of values must be missing in the D36 column.

Add links to the Metabase, Ms, Report, Stat, Tab system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    ReportDS: IDmReportDataSource;
    Report: IPrxReport;
    Shs: IPrxSheets;
    Sheet, SheetRes: ITabSheet;
    Method: IDmMethod;
    BackProp: IDmBackPropagation;
    i: Integer;
    Attrs: Array Of Integer;
    Reports: IDmReports;
    DmReport: IDmReport;
Begin
    mb := MetabaseClass.Active;
    // Create a data source that is a regular report
    ReportDS := (New ReportDataSource.Create) As IDmReportDataSource;
    // Get regular report
    Report := mb.ItemByID("REPORT_DATA_DM").Edit As IPrxReport;
    Shs := Report.Sheets;
    // Specify page with data
    Sheet := (Shs.Item(0As IPrxTable).TabSheet;
    ReportDS.TabSheet := Sheet;
    // Specify data range
    ReportDS.Range := Sheet.Cells(00363);
    // Create calculation method
    Method := (New DataMiningMethod.Create) As IDmMethod;
    // Specify method type
    Method.Kind := DmMethodKind.BackPropagation;
    // Set input data source
    Method.InputDataSource := ReportDS;
    // Set data consumer
    Method.OutputDataSource := ReportDS;
    // Set up calculation method parameters
    BackProp := Method.Details As IDmBackPropagation;
    // Determine column for analysis
    BackProp.Target := ReportDS.FieldCount - 1;
    // Set factors that influence analysis
    Attrs := New Integer[ReportDS.FieldCount - 2];
    For i := 0 To Attrs.Length - 1 Do
        Attrs[i] := i + 1;
    End For;
    BackProp.Attributes := Attrs;
    // Perform analysis
    Reports := Method.Execute;
    DmReport := Reports.FindByType(DmReportType.TemplateFill);
    // Check if results can be unloaded
    If ReportDS.SupportsEdit = True Then
        // Unload results to a new report sheet
        Sheet := (Shs.Add("", PrxSheetType.Table) As IPrxTable).TabSheet;
        SheetRes := DmReport.Generate.CopyToTabSheet;
        SheetRes.View.Selection.SelectAll;
        SheetRes.View.Selection.Copy;
        Sheet.Paste;
        (Report As IMetabaseObject).Save;
    Else
        // Display message that unloading is not available
        Debug.WriteLine("Data source does not support editing. " +
            "Results cannot be saved." );
    End If;
End Sub

After executing the example in the REPORT_DATA_DM report in the D36 column missing data is treated by means of back-propagation network. Treatment results are unloaded to a separate sheet and added to the report.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Report;
Imports Prognoz.Platform.Interop.Stat;
Imports Prognoz.Platform.Interop.Tab;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    ReportDS: IDmReportDataSource;
    Report: IPrxReport;
    Shs: IPrxSheets;
    Sheet, SheetRes: TabSheet;
    Method: IDmMethod;
    BackProp: IDmBackPropagation;
    i: Integer;
    Attrs: Array Of Integer;
    Reports: IDmReports;
    DmReport: IDmReport;
Begin
    mb := Params.Metabase;
    // Create a data source that is a regular report
    ReportDS := (New ReportDataSource.Create()) As IDmReportDataSource;
    // Get regular report
    Report := mb.ItemById["REPORT_DATA_DM"].Edit() As IPrxReport;
    Shs := Report.Sheets;
    // Specify page with data
    Sheet := (Shs.Item[0As IPrxTable).TabSheet;
    ReportDS.TabSheet := Sheet;
    // Specify data range
    ReportDS.Range := Sheet.Cells[00363];
    // Create calculation method
    Method := (New DataMiningMethod.Create()) As IDmMethod;
    // Specify method type
    Method.Kind := DmMethodKind.dmmkBackPropagation;
    // Set input data source
    Method.InputDataSource := ReportDS;
    // Set data consumer
    Method.OutputDataSource := ReportDS;
    // Set up calculation method parameters
    BackProp := Method.Details As IDmBackPropagation;
    // Determine column for analysis
    BackProp.Target := ReportDS.FieldCount - 1;
    // Set factors that influence analysis
    Attrs := New Integer[ReportDS.FieldCount - 2];
    For i := 0 To Attrs.Length - 1 Do
        Attrs[i] := i + 1;
    End For;
    BackProp.Attributes := Attrs;
    // Perform analysis
    Reports := Method.Execute();
    DmReport := Reports.FindByType[DmReportType.drtTemplateFill];
    // Check if results can be unloaded
    If ReportDS.SupportsEdit = True Then
        // Unload results to a new report sheet
        Sheet := (Shs.Add("", PrxSheetType.pstTable) As IPrxTable).TabSheet;
        SheetRes := DmReport.Generate().CopyToTabSheet();
        SheetRes.View.Selection.SelectAll();
        SheetRes.View.Selection.Copy();
        Sheet.Paste();
        (Report As IMetabaseObject).Save();
    Else
        // Display message that unloading is not available
        System.Diagnostics.Debug.WriteLine("Data source does not support editing. " +
            "Results cannot be saved." );
    End If;
End Sub;

See also:

IDmReportDataSource