在ASPOSE中使用多个条件的<<if>>语句

huangapple go评论49阅读模式
英文:

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 &lt;&lt;if&gt;&gt; with many conditions:

我需要添加一个具有多个条件的条件 &lt;&lt;if&gt;&gt;

I tried :

&lt;&lt;if [condition1] OR [Condition2]&gt;&gt;
Write something
&lt;&lt;/if&gt;&gt;

我尝试过:

&lt;&lt;if [condition1] OR [Condition2]&gt;&gt;
写一些内容
&lt;&lt;/if&gt;&gt;
&lt;&lt;if [condition1] AND [Condition2]&gt;&gt;
Write something
&lt;&lt;/if&gt;&gt;

但是我尝试的所有语法都失败了。

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 &lt;&lt;if&gt;&gt; with many conditions:

I tried :

&lt;&lt;if [condition1] OR [Condition2]&gt;&gt;
Write something
&lt;&lt;/if&gt;&gt;
&lt;&lt;if [condition1] AND [Condition2]&gt;&gt;
Write something
&lt;&lt;/if&gt;&gt;

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:

&lt;&lt;if [Condition1 || Condition2]&gt;&gt;
Write something
&lt;&lt;/if&gt;&gt;
&lt;&lt;if [Condition1 &amp;&amp; Condition2]&gt;&gt;
Write something
&lt;&lt;/if&gt;&gt;

For example see the following simple code:

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

builder.Writeln(&quot;&lt;&lt;if [1!=1 || 2==2]&gt;&gt;Condition is true&lt;&lt;else&gt;&gt;Condition is false&lt;&lt;/if&gt;&gt;&quot;);
builder.Writeln(&quot;&lt;&lt;if [1!=1 &amp;&amp; 2==2]&gt;&gt;Condition is true&lt;&lt;else&gt;&gt;Condition is false&lt;&lt;/if&gt;&gt;&quot;);

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

doc.Save(@&quot;C:\Temp\out.docx&quot;);

huangapple
  • 本文由 发表于 2023年2月18日 01:16:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/75487368.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定