CopyToTabSheet: ITabSheet;
The CopyToTabSheet method copies data to a separate table.
The method can be used to save analysis results on a separate sheet of regular report.
Executing the example requires that the repository contains a regular report with the REPORT_DATA_DM identifier. The first sheet of the report should 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(0) As IPrxTable).TabSheet;
ReportDS.TabSheet := Sheet;
// Specify data range
ReportDS.Range := Sheet.Cells(0, 0, 36, 3);
// 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 loaded
If ReportDS.SupportsEdit = True Then
// Load 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 loading 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 substituted by means of back-propagation network. Substitution results are loaded to a separate sheet and added to the report.
See also: