英文:
Using many conditions on ASPOSE <<if>> statement
问题
I'm creating a word document to use it with Aspose for document generation.
我正在创建一个用于 Aspose 文档生成的 Word 文档。
I need to add a conditional <<if>>
with many conditions:
我需要添加一个具有多个条件的条件 <<if>>
:
I tried :
<<if [condition1] OR [Condition2]>>
Write something
<</if>>
我尝试过:
<<if [condition1] OR [Condition2]>>
写一些内容
<</if>>
<<if [condition1] AND [Condition2]>>
Write something
<</if>>
但是我尝试的所有语法都失败了。
Can anyone help with this?
有人可以帮助吗?
英文:
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?
答案1
得分: 0
你可以使用常规的C#或Java语法来处理多个条件:
<<if [Condition1 || Condition2]>>
写一些内容
<</if>>
<<if [Condition1 && Condition2]>>
写一些内容
<</if>>
例如,看下面的简单示例代码:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("<<if [1!=1 || 2==2]>>条件为真<<else>>条件为假<</if>>");
builder.Writeln("<<if [1!=1 && 2==2]>>条件为真<<else>>条件为假<</if>>");
ReportingEngine engine= new ReportingEngine();
engine.BuildReport(doc, new object());
doc.Save(@"C:\Temp\out.docx");
英文:
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");
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论