Class Report
Represents a report object.
Inherited Members
Namespace: FastReport
Assembly: FastReport.Base.dll
Syntax
public class Report : Base, IFRSerializable, IParent
Remarks
The instance of this class contains a report. Here are some common actions that can be performed with this object:
- To load a report, use the Load(String) method or call static FromFile(String) method.
- To save a report, call the Save(String) method.
- To register application dataset for use it in a report, call one of the RegisterData methods.
- To pass some parameter to a report, use the SetParameterValue(String, Object) method.
- To design a report, call the
method. - To run a report and preview it, call the
method. Another way is to call the Prepare() method, then call the method. - To run a report and print it, call the
method. Another way is to call the Prepare() method, then call the method. - To load/save prepared report, use one of the LoadPrepared and SavePrepared methods.
- To set up some global properties, use the Config static class
or
component that you can use in the Visual Studio IDE.
The report consists of one or several report pages (pages of the
ReportPage type) and/or dialog forms (pages of the
Examples
This example shows how to create a report instance, load it from a file, register the application data, run and preview.
Report report = new Report();
report.Load("reportfile.frx");
report.RegisterData(application_dataset);
report.Show();
This example shows how to create simple report in code.
Report report = new Report();
// create the report page
ReportPage page = new ReportPage();
page.Name = "ReportPage1";
// set paper width and height. Note: these properties are measured in millimeters.
page.PaperWidth = 210;
page.PaperHeight = 297;
// add a page to the report
report.Pages.Add(page);
// create report title
page.ReportTitle = new ReportTitleBand();
page.ReportTitle.Name = "ReportTitle1";
page.ReportTitle.Height = Units.Millimeters * 10;
// create Text object and put it to the title
TextObject text = new TextObject();
text.Name = "Text1";
text.Bounds = new RectangleF(0, 0, Units.Millimeters * 100, Units.Millimeters * 5);
page.ReportTitle.Objects.Add(text);
// create data band
DataBand data = new DataBand();
data.Name = "Data1";
data.Height = Units.Millimeters * 10;
// add data band to a page
page.Bands.Add(data);
Constructors
Report()
Initializes a new instance of the Report class with default settings.
Declaration
public Report()
Properties
Aborted
Gets a value indicating that report execution was aborted.
Declaration
public bool Aborted { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
AutoFillDataSet
Gets or sets a value indicating whether it is necessary to automatically fill DataSet registered with RegisterData call.
Declaration
public bool AutoFillDataSet { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
If this property is true (by default), FastReport will automatically fill the DataSet with data when you trying to run a report. Set it to false if you want to fill the DataSet by yourself.
BaseReport
Gets or sets the base report file name.
Declaration
public string BaseReport { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
This property contains the name of a report file this report is inherited from. Note: setting this property to non-empty value will clear the report and load the base file into it.
BaseReportAbsolutePath
Gets or sets the absolute path to the parent report.
Declaration
public string BaseReportAbsolutePath { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
This property contains the absolute path to the parent report.
Compressed
Gets or sets a value that specifies whether to compress the report file.
Declaration
public bool Compressed { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
The report file is compressed using the Gzip algorithm. So you can open the compressed report in any zip-compatible archiver.
ConvertNulls
Gets or sets a value indicating whether the null DB value must be converted to zero, false or empty string depending on the data column type.
Declaration
public bool ConvertNulls { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
This property is true by default. If you set it to false, you should check the DB value before you do something with it (for example, typecast it to any type, use it in a expression etc.)
Dictionary
Gets the report's data.
Declaration
public Dictionary Dictionary { get; set; }
Property Value
Type | Description |
---|---|
Dictionary |
Remarks
The dictionary contains all data items such as connections, data sources, parameters, system variables.
DoublePass
Gets or sets a value that specifies whether the report engine should perform the second pass.
Declaration
public bool DoublePass { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
Typically the second pass is necessary to print the number of total pages. It also may be used to perform some calculations on the first pass and print its results on the second pass.
Use the Engine.FirstPass, Engine.FinalPass properties to determine which pass the engine is performing now.
Engine
Gets a reference to the report engine.
Declaration
public ReportEngine Engine { get; }
Property Value
Type | Description |
---|---|
ReportEngine |
Remarks
This property can be used when report is running. In other cases it returns null.
FileName
Gets or sets the name of a file the report was loaded from.
Declaration
public string FileName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
This property is used to support the FastReport.Net infrastructure; typically you don't need to use it.
FinishReportEvent
Gets or sets a script event name that will be fired when the report is finished.
Declaration
public string FinishReportEvent { get; set; }
Property Value
Type | Description |
---|---|
System.String |
GetReportName
Declaration
public string GetReportName { get; }
Property Value
Type | Description |
---|---|
System.String |
GraphicCache
Gets a reference to the graphics cache for this report.
Declaration
public GraphicCache GraphicCache { get; }
Property Value
Type | Description |
---|---|
GraphicCache |
Remarks
This property is used to support the FastReport.Net infrastructure. Do not use it directly.
HasDialogs
Gets a value indicating that this report contains dialog forms.
Declaration
public bool HasDialogs { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
InitialPageNumber
Gets or sets the initial page number for PageN/PageNofM system variables.
Declaration
public int InitialPageNumber { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
IsLoadPrepared
Returns a bool value depending on the .frx or .fpx report was loaded
Declaration
public bool IsLoadPrepared { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsPrepared
Gets a value indicating whether Report is prepared
Declaration
public bool IsPrepared { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
MaxPages
Gets or sets the maximum number of generated pages in a prepared report.
Declaration
public int MaxPages { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
Use this property to limit the number of pages in a prepared report.
MeasureGraphics
Declaration
public IGraphics MeasureGraphics { get; }
Property Value
Type | Description |
---|---|
IGraphics |
Name
This property is not relevant to this class.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
System.String |
NeedRefresh
Gets or sets the flag for refresh.
Declaration
public bool NeedRefresh { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Operation
Gets the report operation that is currently performed.
Declaration
public ReportOperation Operation { get; }
Property Value
Type | Description |
---|---|
ReportOperation |
Pages
Gets the pages contained in this report.
Declaration
public PageCollection Pages { get; }
Property Value
Type | Description |
---|---|
PageCollection |
Remarks
This property contains pages of all types (report and dialog). Use the is/as operators if you want to work with pages of ReportPage type.
Examples
The following code demonstrates how to access the first report page:
ReportPage page1 = report1.Pages[0] as ReportPage;
Parameters
Gets the collection of report parameters.
Declaration
public ParameterCollection Parameters { get; }
Property Value
Type | Description |
---|---|
ParameterCollection |
Remarks
Parameters are displayed in the "Data" window under the "Parameters" node.
Typical use of parameters is to pass some static data from the application to the report. You can print such data, use it in the data row filter, script etc.
Another way to use parameters is to define some reusable piece of code, for example, to define an expression that will return the concatenation of first and second employee name. In this case, you set the parameter's Expression property to something like this: [Employees.FirstName] + " " + [Employees.LastName]. Now this parameter may be used in the report to print full employee name. Each time you access such parameter, it will calculate the expression and return its value.
You can create nested parameters. To do this, add the new Parameter to the Parameters collection of the root parameter. To access the nested parameter, you may use the GetParameter(String) method.
To get or set the parameter's value, use the GetParameterValue(String) and SetParameterValue(String, Object) methods. To set the parameter's expression, use the GetParameter(String) method that returns a Parameter object and set its Expression property.
Password
Gets or sets the report password.
Declaration
public string Password { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
When you try to load the password-protected report, you will be asked for a password. You also may specify the password in this property before loading the report. In this case the report will load silently.
Password-protected report file is crypted using Rijndael algorithm. Do not forget your password! It will be hard or even impossible to open the protected file in this case.
PreparedPages
Gets a pages of the prepared report.
Declaration
public PreparedPages PreparedPages { get; }
Property Value
Type | Description |
---|---|
PreparedPages |
ReferencedAssemblies
Gets or sets an array of assembly names that will be used to compile the report script.
Declaration
public string[] ReferencedAssemblies { get; set; }
Property Value
Type | Description |
---|---|
System.String[] |
Remarks
By default this property contains the following assemblies: "System.dll", "System.Drawing.dll", "System.Windows.Forms.dll", "System.Data.dll", "System.Xml.dll". If your script uses some types from another assemblies, you have to add them to this property.
ReportInfo
Gets or sets the report information such as report name, author, description etc.
Declaration
public ReportInfo ReportInfo { get; set; }
Property Value
Type | Description |
---|---|
ReportInfo |
ReportResourceString
Gets or sets the resource string that contains the report.
Declaration
public string ReportResourceString { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
This property is used by the MS Visual Studio to store the report. Do not use it directly.
Restrictions
This property is not relevant to this class.
Declaration
public Restrictions Restrictions { get; set; }
Property Value
Type | Description |
---|---|
Restrictions |
ScriptLanguage
Gets or sets the script language of this report.
Declaration
public Language ScriptLanguage { get; set; }
Property Value
Type | Description |
---|---|
Language |
Remarks
Note: changing this property will reset the report script to default empty script.
ScriptRestrictions
Gets or sets a set of permissions that will be restricted for the script code.
Declaration
public PermissionSet ScriptRestrictions { get; set; }
Property Value
Type | Description |
---|---|
System.Security.PermissionSet |
Remarks
Since the report script is compiled into .NET assembly, it allows you to do ANYTHING.
For example, you may create a script that will read/write files from/to a disk. This property
is used to restrict such operations.
using System.Security;
using System.Security.Permissions;
...
PermissionSet ps = new PermissionSet(PermissionState.None);
ps.AddPermission(new FileIOPermission(PermissionState.Unrestricted));
report1.ScriptRestrictions = ps;
report1.Prepare();
ScriptText
Gets or sets the report script.
Declaration
public string ScriptText { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
The script contains the ReportScript class that contains all report objects' event handlers and own items such as private fields, properties, methods etc. The script contains only items written by you. Unlike other report generators, the script does not contain report objects declarations, initialization code. It is added automatically when you run the report.
By default this property contains an empty script text. You may see it in the designer when you switch to the Code window.
If you set this property programmatically, you have to declare the FastReport namespace and the ReportScript class in it. Do not declare report items (such as bands, objects, etc) in the ReportScript class: the report engine does this automatically when you run the report.
Security note: since the report script is compiled into .NET assembly, it allows you to do ANYTHING. For example, you may create a script that will read/write files from/to a disk. To restrict such operations, use the ScriptRestrictions property.
SmoothGraphics
Gets or sets a value that specifies if the graphic objects such as bitmaps and shapes should be displayed smoothly.
Declaration
public bool SmoothGraphics { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
StartReportEvent
Gets or sets a script event name that will be fired when the report starts.
Declaration
public string StartReportEvent { get; set; }
Property Value
Type | Description |
---|---|
System.String |
StoreInResources
Gets or sets a value that determines whether to store the report in the application resources. Use this property in the MS Visual Studio IDE only.
Declaration
public bool StoreInResources { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
By default this property is true. When set to false, you should store your report in a file.
Styles
Gets or sets the collection of styles used in this report.
Declaration
public StyleCollection Styles { get; set; }
Property Value
Type | Description |
---|---|
StyleCollection |
Tag
Gets or sets the Tag object of the report.
Declaration
public object Tag { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
TextQuality
Gets or sets a value that specifies the quality of text rendering.
Declaration
public TextQuality TextQuality { get; set; }
Property Value
Type | Description |
---|---|
TextQuality |
Remarks
Note: the default property value is TextQuality.Default. That means the report may look different depending on OS settings. This property does not affect the printout.
UseFileCache
Gets or sets a value that specifies whether to use the file cache rather than memory to store the prepared report pages.
Declaration
public bool UseFileCache { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
Abort()
Aborts the report execution.
Declaration
public void Abort()
AddChild(Base)
Adds a child object to this object's childs.
Declaration
public void AddChild(Base obj)
Parameters
Type | Name | Description |
---|---|---|
Base | obj |
AddReferencedAssembly(IList<String>)
Add the names of the assembly (in addition to the default) that will be used to compile the report script
Declaration
public void AddReferencedAssembly(IList<string> assembly_names)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<System.String> | assembly_names | Assembly's names |
AddReferencedAssembly(String)
Add the name of the assembly (in addition to the default) that will be used to compile the report script
Declaration
public void AddReferencedAssembly(string assembly_name)
Parameters
Type | Name | Description |
---|---|---|
System.String | assembly_name | Assembly name |
Remarks
For example:
report.AddReferencedAssembly("Newtonsoft.Json.dll")
ApplyStyles()
Updates the report component's styles.
Declaration
public void ApplyStyles()
Remarks
Call this method if you change the Styles collection.
Assign(Base)
Copies the contents of another, similar object.
Declaration
public override void Assign(Base source)
Parameters
Type | Name | Description |
---|---|---|
Base | source | Source object to copy the contents from. |
Overrides
Remarks
Call Assign to copy the properties from another object of the same type. The standard form of a call to Assign is
destination.Assign(source);
which tells the destination object to copy the contents of the source object to itself. In this method, all child objects are ignored. If you want to copy child objects, use the AssignAll method.
See Also
BeginInit()
Declaration
public void BeginInit()
Calc(String)
Calculates an expression and returns the result.
Declaration
public object Calc(string expression)
Parameters
Type | Name | Description |
---|---|---|
System.String | expression | The expression to calculate. |
Returns
Type | Description |
---|---|
System.Object | If report is running, returns the result of calculation. Otherwise returns null. |
Remarks
The expression may be any valid expression such as "1 + 2". The expression is calculated in the report script's ReportScript class instance context, so you may refer to any objects available in this context: private fields, methods, report objects.
Calc(String, Variant)
Calculates an expression and returns the result.
Declaration
public object Calc(string expression, Variant value)
Parameters
Type | Name | Description |
---|---|---|
System.String | expression | The expression to calculate. |
Variant | value | The value of currently printing object. |
Returns
Type | Description |
---|---|
System.Object | If report is running, returns the result of calculation. Otherwise returns null. |
Remarks
Do not call this method directly. Use the Calc(string expression) method instead.
CalcExpression(String, Variant)
Returns an expression value.
Declaration
protected virtual object CalcExpression(string expression, Variant value)
Parameters
Type | Name | Description |
---|---|---|
System.String | expression | The expression. |
Variant | value | The value of currently printing object. |
Returns
Type | Description |
---|---|
System.Object | Returns the result of calculation. |
Remarks
This method is for internal use only, do not call it directly.
CanContain(Base)
Gets a value indicating that this object can contain the specified child object.
Declaration
public bool CanContain(Base child)
Parameters
Type | Name | Description |
---|---|---|
Base | child | Child object. |
Returns
Type | Description |
---|---|
System.Boolean | true if this object can contain the specified child object; otherwise, false. |
Clear()
Clears the object's state.
Declaration
public override void Clear()
Overrides
Remarks
This method also disposes all object's children.
Deserialize(FRReader)
Deserializes the object.
Declaration
public override void Deserialize(FRReader reader)
Parameters
Type | Name | Description |
---|---|---|
FRReader | reader | Reader object. |
Overrides
Remarks
Do not call this method directly. You should override it if you are developing a new component for FastReport.
This method is called when the object needs to restore the state. It may happen when:
- loading the report from a file or stream;
- loading the report from the designer's undo buffer;
- assigning another object to this object using the Assign(Base) or AssignAll methods;
- loading the object from the designer's clipboard;
- loading the object from the preview pages.
DeserializeSubItems(FRReader)
Deserializes nested object properties.
Declaration
protected override void DeserializeSubItems(FRReader reader)
Parameters
Type | Name | Description |
---|---|---|
FRReader | reader | Reader object. |
Overrides
Remarks
Typically the object serializes all properties to the single xml item:
<TextObject Name="Text2" Left="18.9" Top="37.8" Width="283.5" Height="28.35"/>
Some objects like DataBand have child objects that serialized in subitems:
<DataBand Name="Data1" Top="163" Width="718.2" Height="18.9">
<TextObject Name="Text3" Left="18.9" Top="37.8" Width="283.5" Height="28.35"/>
</DataBand>
To read such subitems, the DeserializeSubItems
method is used. Base
implementation reads the child objects. You may override it to read some specific subitems.
Dispose(Boolean)
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Overrides
EndInit()
Declaration
public void EndInit()
EnsureInit()
Ensure that static constructor is called.
Declaration
public static void EnsureInit()
Export(ExportBase, Stream)
Exports a report. Report should be prepared using the Prepare() method.
Declaration
public void Export(ExportBase export, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
ExportBase | export | The export filter. |
System.IO.Stream | stream | Stream to save export result to. |
Export(ExportBase, String)
Exports a report. Report should be prepared using the Prepare() method.
Declaration
public void Export(ExportBase export, string fileName)
Parameters
Type | Name | Description |
---|---|---|
ExportBase | export | The export filter. |
System.String | fileName | File name to save export result to. |
FindObject(String)
Searches for an object with given name.
Declaration
public override Base FindObject(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the object to find. |
Returns
Type | Description |
---|---|
Base | Returns a null reference if object is not found |
Overrides
FromFile(String)
Creates the report instance and loads the report from a file.
Declaration
public static Report FromFile(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | The name of the file to load from. |
Returns
Type | Description |
---|---|
Report | The new report instance. |
FromStream(Stream)
Creates the report instance and loads the report from a stream.
Declaration
public static Report FromStream(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to load from. |
Returns
Type | Description |
---|---|
Report | The new report instance. |
FromString(String)
Creates the report instance and loads the report from a string.
Declaration
public static Report FromString(string utf8String)
Parameters
Type | Name | Description |
---|---|---|
System.String | utf8String | The string that contains a stream in UTF8 encoding. |
Returns
Type | Description |
---|---|
Report | The new report instance. |
GenerateReportAssembly(String)
Generates the file (.cs or .vb) that contains the report source code.
Declaration
public void GenerateReportAssembly(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Name of the file. |
Remarks
Use this method to generate the report source code. This code can be attached to your project. In this case, you will need to call the following code to run a report:
SimpleListReport report = new SimpleListReport();
report.RegisterData(your_dataset);
report.Show();
GetChildObjects(ObjectCollection)
Gets a list of child objects.
Declaration
public void GetChildObjects(ObjectCollection list)
Parameters
Type | Name | Description |
---|---|---|
ObjectCollection | list | List to fill with values. |
GetChildOrder(Base)
Returns z-order of the specified child object.
Declaration
public virtual int GetChildOrder(Base child)
Parameters
Type | Name | Description |
---|---|---|
Base | child | Child object. |
Returns
Type | Description |
---|---|
System.Int32 | Z-order of the specified object. |
Remarks
This method must return the index of a specified child object in the internal child list.
GetColumnValue(String)
Gets the data column's value. Automatically converts null value to 0, false or "" depending on the column type.
Declaration
public object GetColumnValue(string complexName)
Parameters
Type | Name | Description |
---|---|---|
System.String | complexName | The name of the data column including the datasource name. |
Returns
Type | Description |
---|---|
System.Object | If report is running, returns the column value. Otherwise returns null. |
Remarks
The return value of this method does not depend on the ConvertNulls property.
Examples
string employeeName = (string)report.GetColumnValue("Employees.FirstName");
GetColumnValueNullable(String)
Gets the data column's value. This method does not convert null values.
Declaration
public object GetColumnValueNullable(string complexName)
Parameters
Type | Name | Description |
---|---|---|
System.String | complexName | The name of the data column including the datasource name. |
Returns
Type | Description |
---|---|
System.Object | If report is running, returns the column value. Otherwise returns null. |
GetDataSource(String)
Gets the datasource with specified name.
Declaration
public DataSourceBase GetDataSource(string alias)
Parameters
Type | Name | Description |
---|---|---|
System.String | alias | Alias name of a datasource. |
Returns
Type | Description |
---|---|
DataSourceBase | The datasource object if found, otherwise null. |
GetParameter(String)
Gets the report parameter with given name.
Declaration
public Parameter GetParameter(string complexName)
Parameters
Type | Name | Description |
---|---|---|
System.String | complexName | The name of the parameter. |
Returns
Type | Description |
---|---|
Parameter | The Parameter object if found, otherwise null. |
Remarks
To find nested parameter, use the "." separator: "MainParameter.NestedParameter"
GetParameterValue(String)
Gets a value of the parameter with given name.
Declaration
public object GetParameterValue(string complexName)
Parameters
Type | Name | Description |
---|---|---|
System.String | complexName | The name of the parameter. |
Returns
Type | Description |
---|---|
System.Object | The parameter's value if found, otherwise null. |
Remarks
To find nested parameter, use the "." separator: "MainParameter.NestedParameter"
GetTotalValue(String)
Gets a value of the total with specified name.
Declaration
public Variant GetTotalValue(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of total. |
Returns
Type | Description |
---|---|
Variant | The total's value if found, otherwise 0. |
Remarks
This method converts null values to 0 if the ConvertNulls property is set to true. Use the GetTotalValueNullable(String) method if you don't want the null conversion.
GetTotalValueNullable(String)
Gets a value of the total with specified name.
Declaration
public Variant GetTotalValueNullable(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of total. |
Returns
Type | Description |
---|---|
Variant | The total's value if found, otherwise null. |
GetVariableValue(String)
Gets a value of the system variable with specified name.
Declaration
public object GetVariableValue(string complexName)
Parameters
Type | Name | Description |
---|---|---|
System.String | complexName | Name of a variable. |
Returns
Type | Description |
---|---|
System.Object | The variable's value if found, otherwise null. |
InteractiveRefresh()
Refresh prepared report after interactive actions.
Declaration
public void InteractiveRefresh()
InternalInit()
Initializes the report's fields.
Declaration
protected void InternalInit()
Remarks
This method is for internal use only.
InvokeMethod(String, Object[])
Invokes the script method with given name.
Declaration
public object InvokeMethod(string name, object[] parms)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the script method. |
System.Object[] | parms | The method parameters. |
Returns
Type | Description |
---|---|
System.Object |
Load(Stream)
Loads report from a stream.
Declaration
public void Load(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to load from. |
Remarks
The stream must be seekable. When you load a password-protected report, you should specify a password in the Password property, otherwise you will get the DecryptException. In this case you should ask for a password and try again:
try
{
report.Load(stream);
}
catch (DecryptException)
{
report.Password = report.ShowPasswordForm(); // or use your own form to do this
report.Load(stream);
}
Load(String)
Loads the report from a file.
Declaration
public void Load(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | The name of the file to load from. |
Remarks
When you try to load the password-protected report, you will be asked for a password. You also may specify the password in the Password property before loading the report. In this case the report will load silently.
LoadFromString(String)
Loads the report from a string.
Declaration
public void LoadFromString(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string that contains a stream in UTF8 or Base64 encoding. |
LoadPrepared(Stream)
Loads the prepared report from a .fpx file.
Declaration
public void LoadPrepared(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Stream to load from. |
LoadPrepared(String)
Loads the prepared report from a .fpx file.
Declaration
public void LoadPrepared(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | File name to load form. |
OnExportParameters(ExportParametersEventArgs)
Runs the Export event.
Declaration
public void OnExportParameters(ExportParametersEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
ExportParametersEventArgs | e | ExportReportEventArgs object. |
OnFinishReport(EventArgs)
This method fires the FinishReport event and the script code connected to the FinishReportEvent.
Declaration
public void OnFinishReport(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e |
OnStartReport(EventArgs)
This method fires the StartReport event and the script code connected to the StartReportEvent.
Declaration
public void OnStartReport(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e |
PostNameProcess(String, Int32)
Create name for all unnamed elements with prefix and start with number
Declaration
public void PostNameProcess(string prefix, int number)
Parameters
Type | Name | Description |
---|---|---|
System.String | prefix | Prefix for name |
System.Int32 | number | Number from which to start |
Prepare()
Prepares the report.
Declaration
public bool Prepare()
Returns
Type | Description |
---|---|
System.Boolean | true if report was prepared succesfully. |
Prepare(Boolean)
Prepares the report.
Declaration
public bool Prepare(bool append)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | append | Specifies whether the new report should be added to a report that was prepared before. |
Returns
Type | Description |
---|---|
System.Boolean | true if report was prepared successfully. |
Remarks
Use this method to merge prepared reports.
Examples
This example shows how to merge two reports and preview the result:
Report report = new Report();
report.Load("report1.frx");
report.Prepare();
report.Load("report2.frx");
report.Prepare(true);
report.ShowPrepared();
Prepare(Boolean, Boolean)
Prepares the report.
Declaration
public bool Prepare(bool append, bool resetDataState)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | append | Specifies whether the new report should be added to a report that was prepared before. |
System.Boolean | resetDataState | Specifies whether the reset data state. |
Returns
Type | Description |
---|---|
System.Boolean | true if report was prepared successfully. |
Remarks
Use this method to merge prepared reports.
Examples
This example shows how to merge two reports and preview the result:
Report report = new Report();
report.Load("report1.frx");
report.Prepare();
report.Load("report2.frx");
report.Prepare(true);
report.ShowPrepared();
Prepare(Int32)
Prepares the report with pages limit.
Declaration
public bool Prepare(int pagesLimit)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pagesLimit | Pages limit. The number of pages equal or less will be prepared. |
Returns
Type | Description |
---|---|
System.Boolean | true if report was prepared succesfully. |
PrepareAsync(Boolean, Boolean, CancellationToken)
Declaration
public async Task<bool> PrepareAsync(bool append, bool resetDataState, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | append | |
System.Boolean | resetDataState | |
System.Threading.CancellationToken | token |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> |
PrepareAsync(Boolean, CancellationToken)
Declaration
public Task<bool> PrepareAsync(bool append, CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | append | |
System.Threading.CancellationToken | token |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> |
PrepareAsync(CancellationToken)
Prepares the report asynchronously.
Declaration
public Task<bool> PrepareAsync(CancellationToken token = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | token | Cancellation token |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | true if report was prepared successfully. |
PreparePage(ReportPage)
Prepare page
Declaration
public void PreparePage(ReportPage page)
Parameters
Type | Name | Description |
---|---|---|
ReportPage | page |
PreparePage(ReportPage, Boolean)
Prepare page
Declaration
public void PreparePage(ReportPage page, bool isDetailPage)
Parameters
Type | Name | Description |
---|---|---|
ReportPage | page | |
System.Boolean | isDetailPage | Flag indicating whether the page is a detail page. |
PreparePhase1()
For internal use only.
Declaration
public void PreparePhase1()
PreparePhase1Async(CancellationToken)
For internal use only.
Declaration
public async Task PreparePhase1Async(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
PreparePhase2(Nullable<Int32>)
For internal use only.
Declaration
public void PreparePhase2(int? pagesLimit = null)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Int32> | pagesLimit |
Refresh()
Refresh the current report.
Declaration
public void Refresh()
Remarks
Call this method in the Click or MouseUp event handler of a report object to refresh the currently previewed report. Report will be generated again, but without dialog forms.
RegisterData(DataRelation, String)
Registers the application data relation to use it in the report.
Declaration
public void RegisterData(DataRelation data, string name)
Parameters
Type | Name | Description |
---|---|---|
DataRelation | data | The application data. |
System.String | name | The name of the data. |
Remarks
You may specify any value for the name parameter: it is not displayed anywhere in the designer and used only to load/save a report. The name must be persistent and unique for each registered relation.
Examples
report1.Load("report.frx");
report1.RegisterData(myDataRelation, "myRelation");
RegisterData(DataSet)
Registers the application dataset with all its tables and relations to use it in the report.
Declaration
public void RegisterData(DataSet data)
Parameters
Type | Name | Description |
---|---|---|
DataSet | data | The application data. |
Remarks
If you register more than one dataset, use the RegisterData(DataSet, String) method.
Examples
report1.Load("report.frx");
report1.RegisterData(dataSet1);
RegisterData(DataSet, Boolean)
Registers the application dataset with all its tables and relations to use it in the report and enables all its tables.
Declaration
public void RegisterData(DataSet data, bool enableAllTables)
Parameters
Type | Name | Description |
---|---|---|
DataSet | data | The application data. |
System.Boolean | enableAllTables | The boolean value indicating whether all tables should be enabled. |
Remarks
If you register more than one dataset, use the RegisterData(DataSet, String) method.
Examples
report1.Load("report.frx");
report1.RegisterData(dataSet1, true);
RegisterData(DataSet, String)
Registers the application dataset with specified name.
Declaration
public void RegisterData(DataSet data, string name)
Parameters
Type | Name | Description |
---|---|---|
DataSet | data | The application data. |
System.String | name | The name of the data. |
Remarks
Use this method if you register more than one dataset. You may specify any value for the name parameter: it is not displayed anywhere in the designer and used only to load/save a report. The name must be persistent and unique for each registered dataset.
Examples
report1.Load("report.frx");
report1.RegisterData(dataSet1, "NorthWind");
RegisterData(DataSet, String, Boolean)
Registers the application dataset with specified name and enables all its tables.
Declaration
public void RegisterData(DataSet data, string name, bool enableAllTables)
Parameters
Type | Name | Description |
---|---|---|
DataSet | data | The application data. |
System.String | name | The name of the data. |
System.Boolean | enableAllTables | The boolean value indicating whether all tables should be enabled. |
Remarks
Use this method if you register more than one dataset. You may specify any value for the name parameter: it is not displayed anywhere in the designer and used only to load/save a report. The name must be persistent and unique for each registered dataset.
Examples
report1.Load("report.frx");
report1.RegisterData(dataSet1, "NorthWind", true);
RegisterData(DataTable, String)
Registers the application data table to use it in the report.
Declaration
public void RegisterData(DataTable data, string name)
Parameters
Type | Name | Description |
---|---|---|
DataTable | data | The application data. |
System.String | name | The name of the data. |
Examples
report1.Load("report.frx");
report1.RegisterData(dataSet1.Tables["Orders"], "Orders");
RegisterData(DataView, String)
Registers the application data view to use it in the report.
Declaration
public void RegisterData(DataView data, string name)
Parameters
Type | Name | Description |
---|---|---|
DataView | data | The application data. |
System.String | name | The name of the data. |
Examples
report1.Load("report.frx");
report1.RegisterData(myDataView, "OrdersView");
RegisterData(IBaseCubeLink, String)
Registers the application cube link to use it in the report.
Declaration
public void RegisterData(IBaseCubeLink data, string name)
Parameters
Type | Name | Description |
---|---|---|
IBaseCubeLink | data | The application data. |
System.String | name | The name of the data. |
Examples
report1.Load("report.frx");
report1.RegisterData(myCubeLink, "Orders");
RegisterData(IEnumerable, String)
Registers the application business object to use it in the report.
Declaration
public void RegisterData(IEnumerable data, string name)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable | data | Application data. |
System.String | name | Name of the data. |
Examples
report1.Load("report.frx");
report1.RegisterData(myBusinessObject, "Customers");
RegisterData(IEnumerable, String, BOConverterFlags, Int32)
Obsolete. Registers the application business object to use it in the report.
Declaration
public void RegisterData(IEnumerable data, string name, BOConverterFlags flags, int maxNestingLevel)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable | data | Application data. |
System.String | name | Name of the data. |
BOConverterFlags | flags | Not used. |
System.Int32 | maxNestingLevel | Maximum nesting level of business objects. |
Remarks
This method is obsolete. Use the RegisterData(IEnumerable, String) method instead.
RegisterData(IEnumerable, String, Int32)
Registers the application business object to use it in the report.
Declaration
public void RegisterData(IEnumerable data, string name, int maxNestingLevel)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable | data | Application data. |
System.String | name | Name of the data. |
System.Int32 | maxNestingLevel | Maximum nesting level of business objects. |
Remarks
This method creates initial datasource with specified nesting level. It is useful if you create a report in code. In most cases, you don't need to specify the nesting level because it may be selected in the designer's "Choose Report Data" dialog.
RemoveChild(Base)
Removes a specified object from this object's childs.
Declaration
public void RemoveChild(Base obj)
Parameters
Type | Name | Description |
---|---|---|
Base | obj |
Save(Stream)
Saves the report to a stream.
Declaration
public void Save(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to save to. |
Save(Stream, Boolean)
Saves the report to a stream.
Declaration
public void Save(Stream stream, bool savePageLinks)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to save to. |
System.Boolean | savePageLinks | Enables saving linked pages to original files. |
Save(String)
Saves the report to a file.
Declaration
public void Save(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | The name of the file to save to. |
Save(String, Boolean)
Saves the report to a file.
Declaration
public void Save(string fileName, bool savePageLinks)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | The name of the file to save to. |
System.Boolean | savePageLinks | Enables saving linked pages to original files. |
SavePrepared(Stream)
Saves the prepared report. Report should be prepared using the Prepare() method.
Declaration
public void SavePrepared(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Stream to save to. |
SavePrepared(String)
Saves the prepared report. Report should be prepared using the Prepare() method.
Declaration
public void SavePrepared(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | File name to save to. |
SaveToString()
Saves the report to a string.
Declaration
public string SaveToString()
Returns
Type | Description |
---|---|
System.String | The string that contains a stream. |
SaveToString(Boolean)
Saves the report to a string.
Declaration
public string SaveToString(bool savePageLinks)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | savePageLinks | Enables saving linked pages to original files. |
Returns
Type | Description |
---|---|
System.String | The string that contains a stream. |
SaveToStringBase64()
Saves the report to a string using the Base64 encoding.
Declaration
public string SaveToStringBase64()
Returns
Type | Description |
---|---|
System.String | The string that contains a stream. |
SaveWithRandomData(Stream)
Saves the report to a stream with randomized values in data sources.
Declaration
public void SaveWithRandomData(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream to save to. |
SaveWithRandomData(String)
Saves the report to a file with randomized values in data sources.
Declaration
public void SaveWithRandomData(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | The name of the file to save to. |
Serialize(FRWriter)
Serializes the object.
Declaration
public override void Serialize(FRWriter writer)
Parameters
Type | Name | Description |
---|---|---|
FRWriter | writer | Writer object. |
Overrides
Remarks
Do not call this method directly. You should override it if you are developing a new component for FastReport.
This method is called when the object needs to save the state. It may happen when:
- saving the report to the file or stream;
- saving the report to the designer's undo buffer;
- assigning the object to another object using the Assign(Base) or AssignAll methods;
- saving the object to the designer's clipboard;
- saving the object to the preview (when run a report).
SetChildOrder(Base, Int32)
Sets the z-order of the specified object.
Declaration
public virtual void SetChildOrder(Base child, int order)
Parameters
Type | Name | Description |
---|---|---|
Base | child | Child object. |
System.Int32 | order | New Z-order. |
Remarks
This method must place the specified child object at the specified position in the internal child list.
SetParameterExpression(String, String)
Sets the parameter's expression.
Declaration
public void SetParameterExpression(string complexName, string expression)
Parameters
Type | Name | Description |
---|---|---|
System.String | complexName | The name of the parameter. |
System.String | expression | Epression to set. It must be a valid FR expression. |
Remarks
This method is used to create an expression for a parameter.
If the specified parameter does not exist, it will be created with the specified expression.
Expression must be a valid FR expression to avoid exceptions.
SetParameterValue(String, Object)
Sets the parameter's value.
Declaration
public void SetParameterValue(string complexName, object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | complexName | The name of the parameter. |
System.Object | value | Value to set. |
Remarks
Use this method to pass a value to the parameter that you've created in the "Data" window. Such parameter may be used everythere in a report; for example, you can print its value or use it in expressions.
You should call this method after the report was loaded and before you run it.
To access a nested parameter, use the "." separator: "MainParameter.NestedParameter"
caution
This method will create the parameter if it does not exist.
Examples
This example shows how to pass a value to the parameter with "MyParam" name:
// load the report
report1.Load("report.frx");
// setup the parameter
report1.SetParameterValue("MyParam", 10);
// show the report
report1.Show();
SetPreparedPages(PreparedPages)
Sets prepared pages.
Declaration
public void SetPreparedPages(PreparedPages pages)
Parameters
Type | Name | Description |
---|---|---|
PreparedPages | pages |
UpdateLayout(Single, Single)
Updates the children layout when the size of this object is changed by dx, dy values.
Declaration
public virtual void UpdateLayout(float dx, float dy)
Parameters
Type | Name | Description |
---|---|---|
System.Single | dx | X delta. |
System.Single | dy | Y delta. |
Remarks
This method must update positions/sizes of child objects whose Dock or Anchor properties are set to non-default values.
Xml(String)
Serialize report object from string
Declaration
public ReportComponentBase Xml(string xml)
Parameters
Type | Name | Description |
---|---|---|
System.String | xml |
Returns
Type | Description |
---|---|
ReportComponentBase | Serialized report object from string |
Events
CustomCalc
Occurs when calc execution is started.
Declaration
public event CustomCalcEventHandler CustomCalc
Event Type
Type | Description |
---|---|
CustomCalcEventHandler |
ExportParameters
Occurs before export to set custom export parameters.
Declaration
public event EventHandler<ExportParametersEventArgs> ExportParameters
Event Type
Type | Description |
---|---|
System.EventHandler<ExportParametersEventArgs> |
FinishReport
Occurs when report execution is finished.
Declaration
public event EventHandler FinishReport
Event Type
Type | Description |
---|---|
System.EventHandler |
LoadBaseReport
Occurs when report is inherited and trying to load a base report.
Declaration
public event CustomLoadEventHandler LoadBaseReport
Event Type
Type | Description |
---|---|
CustomLoadEventHandler |
Remarks
Typical use of this event is to load the base report from a database instead of a file.
StartReport
Occurs when report execution is started.
Declaration
public event EventHandler StartReport
Event Type
Type | Description |
---|---|
System.EventHandler |