ExportToFile(FileName: String; FormatTag: String);
ExportToFile(FileName: String; FormatTag: String);
FileName. File name, to which export is performed.
FormatTag. File format, to which export is performed. Various export types are available depending on the exported file.
The ExportToFile method exports an object to a file of the specified format.
The description of export features of specific object types is presented in the sections:
Maps and charts contained in a dashboard are exported as an image.
The following formats of dashboards export are available:
Excel workbook (*.xls).
PDF document (*.pdf).
RTF document (*.rtf).
Web page, single file archive (*.mht).
EMF document (*.emf).
PowerPoint presentation (*.ppxt).
Executing the example requires that the repository contains a dashboard with the ADHOC identifier containing a block with the IQY1DKCFA3U5BTQP identifier.
Add links to the Metabase, AdHoc system assemblies.
Sub UserProc;
Var
mb: IMetabase;
Rep: IAdhocReport;
Ex: IAdhocReportExporter;
Begin
mb := MetabaseClass.Active;
// Get dashboard
Rep := mb.ItemById("ADHOC").Bind As IAdhocReport;
// Create an export object
Ex := New AdhocReportExporter.Create;
// Specify exported panel
Ex.AdhocReport := Rep;
// Specify exported block
Ex.DataSources := "IQY1DKCFA3U5BTQP";
// Execute export
Ex.ExportToFile("C:\Dashboard.xls", "XLS");
End Sub UserProc;
After executing the example the block with the IQY1DKCFA3U5BTQP identifier is exported to the C:\Dashboard.xls file.
A workspace can be exported to the following formats:
bmp.
png.
jpg.
gif.
tiff.
The following example requires the ws object of the IWxWorkspace type.
Sub UserProc;
Var
ws: IWxWorkspace;
view : IWxView;
Exp: IWxViewExporter;
Begin
view := ws.CreateView;
Exp := New WxViewExporter.Create;
Exp.WxView := view;
Exp.ExportToFile("C:\WS.gif","gif");
End Sub UserProc;
Executing the example will export a workspace into the WS.gif file.
The chart export is available to the following formats:
jpg.
bmp.
png.
tiff.
gif.
html.
xaml.
The following example requires the Chart object of the IChart type and the UiChart component.
Sub User;
Var
Chart : IChart;
Exp: IChartExporter;
Begin
Chart := UiChart1.Chart;
Exp := New ChartExporter.Create;
Exp.Chart := Chart;
Exp.Scale := 0.5;
Exp.ExportToFile("C:\Chart.jpg","jpg");
End Sub User;
After executing the example the chart is exported to a file of the specified format.
A 3D scene can be exported to the following formats:
jpg.
bmp.
png.
tiff.
gif.
html.
An express report can be exported to the following formats:
mht.
html.
pdf.
xls.
xlsx.
rtf.
emf.
pptx.
NOTE. If an export of several reports to one file is required, use the ExportToFile method together with IExAnalyzerExporter.StartBatchCommand and IExAnalyzerExporter.FinishBatchCommand.
The example requires the Analyzer object of the IEaxAnalyzer type.
Sub UserProc;
Var
Analazer: IEaxAnalyzer;
Exp: IExAnalyzerExporter;
Begin
exp := New ExAnalyzerExporter.Create;
exp.ExAnalyzer := Analazer;
exp.ExportToFile("C:\Analazer.xls", "XLS");
End Sub UserProc;
After executing the example the express report is exported to a file of the specified format.
A map can be exported to the following formats:
jpg.
bmp.
png.
tiff.
gif.
html.
xaml.
The following example requires the Report object of the IPrxReport type.
Sub UserProc;
Var
Report : IPrxReport;
TabObj: ITabObject;
exp: MapExporter;
Map: IMap;
Begin
TabObj := (Report.Sheets.Item(0) As IPrxTable).TabSheet.Objects.Item(0);
Map := TabObj.Extension As IMap;
exp := New MapExporter.Create;
exp.Map := Map;
exp.PixelHeight := 300;
exp.PixelWidth := 500;
exp.Scale := 0.5;
exp.ExportToFile("d:\map.jpg", "jpg");
End Sub UserProc;
After executing the example a map is exported to a file of the specified format (jpg).
A regular report can be exported to the following formats:
xlsx.
xls.
pdf.
rtf.
ppxt.
html.
mht.
ods.
emf.
png. For correct export of a regular report to the png format, determine a range of exported sheets.
If an export of several reports to one file is required, use the ExportToFile method together with IExAnalyzerExporter.StartBatchCommand and IExAnalyzerExporter.FinishBatchCommand methods.
This example requires the Report object of the IPrxReport type.
Add links to the Metabase, Report system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Report: IPrxReport;
Exp: IPrxReportExporter;
Begin
MB := MetabaseClass.Active;
Exp := New PrxReportExporter.Create;
Exp.Report := Report;
Exp.ExportSheetTitles := True;
Exp.ExportRange := "4:0";
Exp.ExportToFile("C:\" + Report.Name + ".png", "png");
End Sub UserProc;
After executing the example, a regular report is exported into the file with PNG format. Sheet names will be in output file.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Report;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Report: IPrxReport;
Exp: IPrxReportExporter;
Begin
MB := Params.Metabase;
Exp := New PrxReportExporter.Create();
Exp.Report := Report;
Exp.ExportSheetTitles := True;
Exp.ExportRange := "4:0";
Exp.ExportToFile("C:\" + Report.Name + ".png", "png");
End Sub;
Table icons can be exported to the following formats:
png.
jpg.
bmp.
gif.
tiff.
This example requires the Report object of the IPrxReport type, which sheet contains icons, for example:
Sub UserProc;
Var
Report: IPrxReport;
Exp: ITabIconExporter;
Begin
Exp := New TabIconExporter.Create;
Exp.TabSheet := (Report.Sheets.Item(0) As IPrxTable).TabSheet;
Exp.IconIndex := 0;
Exp.ExportToFile("C:\Icon1.bmp","bmp");
End Sub UserProc;
After executing the example the first sheet icon is exported to a file with the specified format.
A table can be exported to the following formats:
gif.
jpg.
bmp.
gif.
tiff.
XAML (for charts only).
This example requires the Report object of the IPrxReport type.
Sub UserProc;
Var
Report: IPrxReport;
Exp: ITabObjectExporter;
Tab: ITabSheet;
Obj: ITabObject;
Begin
Tab := (Report.Sheets.Item(0) As IPrxTable).TabSheet;
Obj := Tab.Objects.Item(0);
Exp := New TabObjectExporter.Create;
Exp.Object := Obj;
Exp.ExportToFile("C:\Obj.gif","gif");
End Sub UserProc;
After executing the example the object of the regular report sheet is exported to the file of the specified format.
A regular report sheet can be exported to the following formats:
html.
mht.
pdf.
xls.
xlsx.
rtf.
ods.
emf
pptx.
This example requires the Report object of the IPrxReport type.
Sub UserProc;
Var
Report: IPrxReport;
Tab: ITabSheet;
Exp: ITabSheetExporter;
Begin
Tab := (Report.Sheets.Item(0) As IPrxTable).TabSheet;
Exp := New TabSheetExporter.Create;
Exp.TabSheet := Tab;
Exp.ExportObjects := False;
Exp.ExportToFile("c:\Report.xls", "XLS");
End Sub UserProc;
After executing the example the regular report sheet is exported to the file of the XLS format. The objects located on the table sheet are not exported.
See also: