0

I'm creating a word document to use it with Aspose for document generation.

I need to add a conditional <<if>> with many conditions:

I tried :

<<if [condition1] OR [Condition2]>>
Write something
<</if>>
<<if [condition1] AND [Condition2]>>
Write something
<</if>>

but all the syntaxes I tried failed.

Can anyone help with this?

Alexey Noskov
  • 1,722
  • 1
  • 7
  • 13
MAyadi
  • 13
  • 3

1 Answers1

0

You can use regular C# or Java syntax for multiple conditions:

<<if [Condition1 || Condition2]>>
Write something
<</if>>
<<if [Condition1 && Condition2]>>
Write something
<</if>>

For example see the following simple code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("<<if [1!=1 || 2==2]>>Condition is true<<else>>Condition is false<</if>>");
builder.Writeln("<<if [1!=1 && 2==2]>>Condition is true<<else>>Condition is false<</if>>");

ReportingEngine engine= new ReportingEngine();
engine.BuildReport(doc, new object());

doc.Save(@"C:\Temp\out.docx");
Alexey Noskov
  • 1,722
  • 1
  • 7
  • 13