java.lang.Object
com.aspose.words.ReportingEngine
public class ReportingEngine
To learn more, visit the LINQ Reporting Engine documentation article.
| Constructor Summary |
|---|
ReportingEngine()
Initializes a new instance of this class. |
| Property Getters/Setters Summary | ||
|---|---|---|
KnownTypeSet | getKnownTypes() | |
|
Gets an unordered set (i.e. a collection of unique items) containing |
||
java.lang.String | getMissingMemberMessage() | |
void | setMissingMemberMessage(java.lang.String value) | |
| Gets or sets a string value printed instead of a template expression that represents a plain reference to a missing member of an object. The default value is an empty string. | ||
int | getOptions() | |
void | setOptions(int value) | |
|
Gets or sets a set of flags controlling behavior of this |
||
static boolean | getUseReflectionOptimization() | |
static void | setUseReflectionOptimization(boolean value) | |
Gets or sets a value indicating whether invocations of custom type members performed via reflection API are
optimized using dynamic class generation or not. The default value is true.
|
||
| Method Summary | ||
|---|---|---|
boolean | buildReport(Document document, java.lang.Object dataSource) | |
| Populates the specified template document with data from the specified source making it a ready report. | ||
boolean | buildReport(Document document, java.lang.Object dataSource, java.lang.String dataSourceName) | |
| Populates the specified template document with data from the specified source making it a ready report. | ||
boolean | buildReport(Document document, java.lang.Object[] dataSources, java.lang.String[] dataSourceNames) | |
| Populates the specified template document with data from the specified sources making it a ready report. | ||
boolean | equals(java.lang.Object obj) | |
| Determines whether the specified object is equal in value to the current object. | ||
static java.lang.Class[] | getRestrictedTypes() | |
| Returns types, which members as well as which derived types' members should be inaccessible by the engine through template syntax. | ||
static void | setRestrictedTypes(java.lang.Class[] types) | |
| Specifies types, which members as well as which derived types' members should be inaccessible by the engine through template syntax. | ||
| Constructor Detail |
|---|
public ReportingEngine()
| Property Getters/Setters Detail |
|---|
getKnownTypes | |
public KnownTypeSet getKnownTypes() | |
getMissingMemberMessage/setMissingMemberMessage | |
public java.lang.String getMissingMemberMessage() / public void setMissingMemberMessage(java.lang.String value) | |
The property should be used in conjunction with the
The property affects only printing of a template expression representing a plain reference to a missing object member. For example, printing of a binary operator, one of which operands references a missing object member, is not affected.
The value of this property cannot be set to null.
Example:
Shows how to allow missinng members.
DocumentBuilder builder = new DocumentBuilder();
builder.writeln("<<[missingObject.First().id]>>");
builder.writeln("<<foreach [in missingObject]>><<[id]>><</foreach>>");
ReportingEngine engine = new ReportingEngine(); { engine.setOptions(ReportBuildOptions.ALLOW_MISSING_MEMBERS); }
engine.setMissingMemberMessage("Missed");
engine.buildReport(builder.getDocument(), new DataSet(), "");getOptions/setOptions | |
public int getOptions() / public void setOptions(int value) | |
Example:
Shows how to allow missinng members.
DocumentBuilder builder = new DocumentBuilder();
builder.writeln("<<[missingObject.First().id]>>");
builder.writeln("<<foreach [in missingObject]>><<[id]>><</foreach>>");
ReportingEngine engine = new ReportingEngine(); { engine.setOptions(ReportBuildOptions.ALLOW_MISSING_MEMBERS); }
engine.setMissingMemberMessage("Missed");
engine.buildReport(builder.getDocument(), new DataSet(), "");Example:
Shows how to set options for Reporting Engine
Document doc = new Document(getMyDir() + "Reporting engine template - Fields (Java).docx");
// Note that enabling of the option makes the engine to update fields while building a report,
// so there is no need to update fields separately after that.
ReportingEngine engine = new ReportingEngine();
engine.setOptions(ReportBuildOptions.UPDATE_FIELDS_SYNTAX_AWARE);
engine.buildReport(doc, new String[] { "First topic", "Second topic", "Third topic" }, "topics");
doc.save(getArtifactsDir() + "ReportingEngine.UpdateFieldsSyntaxAware.docx");getUseReflectionOptimization/setUseReflectionOptimization | |
public static boolean getUseReflectionOptimization() / public static void setUseReflectionOptimization(boolean value) | |
true.
| Method Detail |
|---|
buildReport | |
public boolean buildReport(Document document, java.lang.Object dataSource) throws java.lang.Exception | |
Using this overload you can reference the data source's members in the template document, but you cannot
reference the data source object itself. You should use the
A data source object can be of one of the following types:
For information on how to work with data sources of different types in template documents, see template syntax reference (https://docs.aspose.com/display/wordsjava/Template+Syntax).
document - A template document to be populated with data.dataSource - A data source object.buildReport | |
public boolean buildReport(Document document, java.lang.Object dataSource, java.lang.String dataSourceName) throws java.lang.Exception | |
Using this overload you can reference the data source's members and the data source object itself in the template.
If you are not going to reference the data source object itself, you can omit dataSourceName
passing null or use the
A data source object can be of one of the following types:
For information on how to work with data sources of different types in template documents, see template syntax reference (https://docs.aspose.com/display/wordsjava/Template+Syntax).
document - A template document to be populated with data.dataSource - A data source object.dataSourceName - A name to reference the data source object in the template.Example:
Shows how to display values as dollar text.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("<<[ds.getValue1()]:dollarText>>\r<<[ds.getValue2()]:dollarText>>");
NumericTestClass testData = new NumericTestBuilder().withValues(1234, 5621718.589).build();
ReportingEngine report = new ReportingEngine();
report.getKnownTypes().add(NumericTestClass.class);
report.buildReport(doc, testData, "ds");
doc.save(getArtifactsDir() + "ReportingEngine.DollarTextFormat.docx");Example:
Shows how to allow missinng members.
DocumentBuilder builder = new DocumentBuilder();
builder.writeln("<<[missingObject.First().id]>>");
builder.writeln("<<foreach [in missingObject]>><<[id]>><</foreach>>");
ReportingEngine engine = new ReportingEngine(); { engine.setOptions(ReportBuildOptions.ALLOW_MISSING_MEMBERS); }
engine.setMissingMemberMessage("Missed");
engine.buildReport(builder.getDocument(), new DataSet(), "");Example:
Shows how to remove paragraphs selectively.// Template contains tags with an exclamation mark. For such tags, empty paragraphs will be removed. Document doc = new Document(getMyDir() + "Reporting engine template - Selective remove paragraphs.docx"); ReportingEngine engine = new ReportingEngine(); engine.buildReport(doc, false, "value"); doc.save(getArtifactsDir() + "ReportingEngine.SelectiveDeletionOfParagraphs.docx");
buildReport | |
public boolean buildReport(Document document, java.lang.Object[] dataSources, java.lang.String[] dataSourceNames) throws java.lang.Exception | |
Using this overload you can reference multiple data source objects and their members in the template.
The name of the first data source can be omitted (i.e. be an empty string or null) if you are going to
reference the data source's members but not the data source object itself. Names of the other data sources
must be specified and unique.
If you are going to use a single data source, consider using of
A data source object can be of one of the following types:
For information on how to work with data sources of different types in template documents, see template syntax reference (https://docs.aspose.com/display/wordsjava/Template+Syntax).
document - A template document to be populated with data.dataSources - An array of data source objects.dataSourceNames - An array of names to reference the data source objects within the template.Example:
Shows how to keep inserted numbering as is.
// By default, numbered lists from a template document are continued when their identifiers match those from a document being inserted.
// With "-sourceNumbering" numbering should be separated and kept as is.
Document template = DocumentHelper.createSimpleDocument("<<doc [src.getDocument()]>>" + System.lineSeparator() + "<<doc [src.getDocument()] -sourceNumbering>>");
DocumentTestClass doc = new DocumentTestBuilder()
.withDocument(new Document(getMyDir() + "List item.docx")).build();
ReportingEngine engine = new ReportingEngine(); { engine.setOptions(ReportBuildOptions.REMOVE_EMPTY_PARAGRAPHS); }
engine.buildReport(template, new Object[] { doc }, new String[] { "src" });
template.save(getArtifactsDir() + "ReportingEngine.SourseListNumbering.docx");Example:
Shows how to work with charts from word 2016.
Document doc = new Document(getMyDir() + "Reporting engine template - Word 2016 Charts (Java).docx");
ReportingEngine engine = new ReportingEngine();
engine.buildReport(doc, new Object[] { Common.getShares(), Common.getShareQuotes() },
new String[] { "shares", "quotes" });
doc.save(getArtifactsDir() + "ReportingEngine.Word2016Charts.docx");equals | |
public boolean equals(java.lang.Object obj) | |
getRestrictedTypes | |
public static java.lang.Class[] getRestrictedTypes() | |
The returned array contains items previously set using
Changing items of the returned array has no effect on restricted types. To change restricted types, use
setRestrictedTypes | |
public static void setRestrictedTypes(java.lang.Class[] types) | |
Restricted types should be set before the very first building of a report. After buildReport is invoked, restricted types cannot be modified and an exception is thrown
on attempt to do this. The best place to set restricted types is application startup.
Note that a big amount of restricted types may affect performance, so it is better to restrict only those types, access to which members is really sensitive.
Throws
- types is null.
- One of types items is null.
- One of types items represents an invisible type, i.e. a non-public type or a public nested type which has a non-public outer type.
- One of types items represents an array type.
- types contain duplicate entries.
types - Types to be restricted.Example:
Shows how to deny access to members of types considered insecure.
Document doc =
DocumentHelper.createSimpleDocument(
"<<var [typeVar = \"\".getClass().getName()]>><<[typeVar]>>");
// Note, that you can't set restricted types during or after building a report.
ReportingEngine.setRestrictedTypes(Class.class);
// We set "AllowMissingMembers" option to avoid exceptions during building a report.
ReportingEngine engine = new ReportingEngine();
engine.setOptions(ReportBuildOptions.ALLOW_MISSING_MEMBERS);
engine.buildReport(doc, new Object());
// We get an empty string because we can't access the GetType() method.
Assert.assertEquals(doc.getText().trim(), "");