Microsoft Excel reporting and 
 data analyzing with practically no coding. 
 .Net, ActiveX, and VCL versions. 
 www.AfalinaSoft.com  

Home    Products    Downloads    Registered users    Support    Prices    Order    Primary Subscription

 

MS Office COM Add-ins. Microsoft Excel reporting 
 and data analyzing


TxlReport Methods - AfalinaSoft XL Report Programmer's Reference

<< Previous

Table of contents

Next >>


TxlReport Methods


AddDataSet public

Adds a dataset to the DataSources collection.

function AddDataSet(ADataSet: TDataSet; ARange: string = '';
AMacroBefore: string = ''; AMacroAfter: string = '';
AOptions: TxlRangeOptionsSet = [xrgoAutoOpen, xrgoPreserveRowHeight];
AOnMacro: TxlOnMacro = nil;
AOnBeforeDataTransfer: TxlDataTransferHandleEvent = nil;
AOnAfterDataTransfer: TxlDataTransferHandleEvent = nil): TxlDataSource;

This method adds a new item to the DataSources collection. The item refers to the ADataSet dataset whose data should be placed in the ARange range. The other method parameters initialize corresponding properties of the item

CreateEx public virtual

Creates an instance of TxlReport class.

constructor CreateEx(AOwner: TComponent; AXLSTemplate: string;
AActiveSheet: string = '';
AMacroBefore: string = ''; AMacroAfter: string = '';
AOptions: TxlReportOptionsSet = [xroDisplayAlerts, xroAutoOpen];
ATempPath: string = '';
AOnBeforeBuild: TxlReportHandleEvent = nil;
AOnAfterBuild: TxlReportHandleEvent = nil); virtual;

A replacement for standard constructor approach.

ConnectToExcelApplication public class method

Allows to use any given instance of Excel.Application.

class procedure ConnectToExcelApplication(OLEObject: OLEVariant);

Can be useful if Excel is used in an application not only for reporting. If xroOptimizeLaunch is set to True, all used interfaces will be freed before the connection is made.

Edit public

Use this method to open a template.

procedure Edit;

Template file must be supplied in XLSTemplate property. If this property is empty, Excel is launched with a new workbook. All event handlers will not be activated.

MergeReports public class method

Creates several reports and merges them in one workbook.

class procedure MergeReports(Reports: array of TxlReport;
SheetPrefixes: array of string); override;

The first parameter of the method is an array of TxlReport - reports that will be merged in a resulting workbook. The process of generation of every report is isolated from the others because each report is created in a separate workbook. This allows to be not bothered with event handlers and/or macros created for some/all reports. After processing the current report, the OnlyValues option will be applied to its visible worksheets and every name (the Name object) will be deleted from them (in order to prevent probable name conflicts). All the reports will be added to the first instance of TxlReport in the Reports array. Every worksheet will be added with its own name prefixed with the prefix taken from the SheetPrefixes parameter. You should ensure that both of the arrays have equal number of elements.

ReleaseExcelApplication public class method

Frees all Excel interfaces.

class procedure ReleaseExcelApplication;

If roOptimizeLaunch flag is True, then once loaded Excel will be unloaded only after the application finishes. You can use this class method if you want to unload Excel.

Report public virtual

Creates a report based on the template specified in the XLSTemplate property.

procedure Report;
procedure Report(const APreview: boolean);
procedure Report(Workbook, ExcelApp: OLEVariant;
const NewWorkbookName: string = '');

The second variant of the Report method is left for compatibility only and isn't recommended for future use. If APreview is true then the report is opened in preview.

The third variant can be used in several ways. If you pas the path and file name of a workbook in the NewWorkbookName parameter, the report will be saved to this workbook. For example,

NewWorkbookName := ExtractFilePath(ParamStr(0)) + 'NewWorkbook.xls';
xlReport1.Report(EmptyParam, EmptyParam, NewWorkbookName);

If you pas the path and file name of a workbook in the Workbook parameter, the report will be saved to this workbook. For example,

ExistingWorkbookName := ExtractFilePath(ParamStr(0)) + 'QReport.xls';
xlReport1.Report(ExistingWorkbookName, EmptyParam);

You can also pass the interface of an open workbook in the Workbook parameter. This helps in case of multiple Excel instances. Example:

var
IXLApp, ITargetWorkbook: OLEVariant;

IXLApp := CreateOLEObject('Excel.Application');
ITargetWorkbook := IXLApp.Workbooks.Open(
ExtractFilePath(ParamStr(0)) + 'Book1.xls');
try
xlReport1.Report(ITargetWorkbook, EmptyParam);
except
IXLApp.Visible := true;
end;

You can also specify a concrete Excel instance in this method via the ExcelApp parameter. Example:

var
IXLApp: OLEvariant;

IXLApp := CreateOLEObject('Excel.Application');
try
xlReport1.Report(EmptyParam, IXLApp);
except
IXLApp.Visible := true;
end;

And finally, you can add a report to an existing workbook and save the resulting workbook under a new name. See below.

ExistingWorkbookName := ExtractFilePath(ParamStr(0)) + 'QReport.xls';
NewWorkbookName := ExtractFilePath(ParamStr(0)) + 'QReport_June.xls';
xlReport1.Report(ExistingWorkbookName, EmptyParam, NewWorkbookName);

Note. An exception arises, if the file specified in the Workbook parameter is missed. Likewise, an exception arises, when XL Report attempts to write to the existing file specified in the NewWorkbookName parameter. You should take care of both situations yourself.

ReportTo public virtual

Creates a report and inserts it into an existing workbook.

procedure ReportTo(const WorkbookName: string; const NewWorkbookName: string = '');

Use this method in order to create a report and insert its worksheets into the workbook specified in the WorkbookName parameter. Then this other workbook can be saved under the name specified in the NewWorkbookName parameter. You can also use this method to create a report and save it under new name taken from the NewWorkbookName parameter. The WorkbookName parameter should be empty in this case. Examples:

// Create a report and save it in the new workbook
Report.ReportTo('', 'C:\Accounting\GrossRevenue.xls');
// Create a report and add it to an existing workbook
Report.ReportTo('C:\Accounting\MonthlyBalance.xls');
// Create a report, add it to an existing workbook, and save it under new name
Report.ReportTo('C:\Accounting\ ProgressiveBalance.xls.xls',
'C:\Accounting\ProgressiveBalance_Sep2001.xls.xls');

<< Previous

Table of contents

Next >>



Components

xlReport xlReport

Developed for

Delphi 4, 5, 6, 7
C++Builder 4, 5, 6

Excel version supported

MS Excel 97 (SR2)
MS Excel 2000
MS Excel 2002 (XP)
MS Excel 2003



[ Download it ]
[ Order now ]



We are Borland 
 technology partner

Copyright © 1999-2006
All right reserved.
Privacy Policy

Write to WebMaster

Page Top
Add-in Express - COM Add-ins, Smart Tags and RTDS in C#, VB, C++, J#, and Delphi