aspose单词合并
我正在使用Aspose库进行单词合并。 在上一个Aspose的上一个版本中,如果我们在合并时添加了一个字段的白色空间,则不会将其视为空的,但是在升级到最新版本后,它将Whitespaces视为空白,并删除这些字段,如果设置已打开。
就我的情况而言,我想预防少数文件的空间或空字段,但将其删除以获取其余的字段。 我试图找到一个可以在现场级别上应用的设置,以防止或删除空字段,但没有任何设置。 有什么办法可以实现这一目标?
I am using Aspose library for Word merge.
In the previous version of the Aspose, if we add white spaces for a field then while merging , it doesn't considers it as empty but after upgrade to latest version, it is considering the whitespaces as blank and removing those fields if setting is ON.
For my case, I want to prevent whitespaces or empty fields for few fileds but remove it for rest of the fields.
I tried to find a setting which can be applied on field level to prevent or remove empty fields but have'nt got any.
Is there any way I can acheive this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果段落仅包含Whitespaces,则将其视为空并删除。因此,例如,如果您使用以下代码:
其中
midname
合并字段放在单独的段落中,则该段落将被删除为空。但是,您可以使用 ifieldMergergeCallback )。例如,您可以将隐藏的文本放在合并字段中,以使段落被视为不为空。例如,请参见以下代码:
稍后,您可以删除隐藏的文本,如果需要。
If paragraph contains only whitespaces it is considered as empty and is removed. So for example if you use code like the following:
Where
MidName
merge field is placed in a separate paragraph, the paragraph will be removed as empty.However, you can work this behavior around using IFieldMergingCallback. For example, you can put hidden text at the merge field to make the paragraph to be considered as not empty. For example see the following code:
Later, you can remove hidden text if required.
假设您实际上正在执行MailMerge(不仅仅是覆盖Mergefields),则应该能够通过MailMermerge Main文档中的MailMermerge字段编码来控制大多数(如果不是全部)。
在PC上,您可以使用MergeField \ b和/或\ f开关来抑制空合菲尔德之前或之后的空间。例如,假设您有:
«title»«firstName»«secondName»«lastName»,
但«secondname»有时为空,您不希望它在输出中留下两个空格。为了处理:
{Mergefield secondname};
取决于抑制的空间是遵循还是在Mergefield之前;
合并菲尔德;
注1: \ b和\ f开关在MACS上不起作用或与其他交换机一起使用。在这种情况下,您需要使用,如果测试,则按照 -
即使这样,您也可以使用\ b和\ f开关来表达具有自己开关的其他MergeFields。例如,假设您有四个字段“产品”,“供应商”,“数量”和“ UnitPrice”,并且如果“供应商”字段为空。在这种情况下,您可能会使用以下行的字段:
注2:字段支撑对(即'{}')在上面的示例中都是通过ctrl在文档本身中创建的-F9(Mac上的CMD-F9或,如果您使用笔记本电脑,则可能需要使用Ctrl-FN-F9);您不能简单地键入它们或复制&从此消息粘贴它们。通过任何标准单词对话添加它们也不是实际的。同样,人字形(即'«»')是实际合并的一部分 - 您可以从'插入合并字段'下拉列表中插入(即您也不能从此消息中键入或复制&粘贴它们)。田间构造中表示的空间都是必需的。您应该分别使用真实的选项卡和行/段落中断,而不是→↵和¶符号。
有关更多 MailMerge Tips&技巧,请参阅: https:// wwww。 msofficeforums.com/mail-merge/21803-mailmerge-tips-tricks.html
Assuming you're actually executing a mailmerge (not just overwriting mergefields), you should be able to control most, if not all, of that via mailmerge field coding in the mailmerge main document.
On PCs, you can use the mergefield \b and/or \f switches to suppress a space before or after an empty mergefield. For example, suppose you have:
«Title» «FirstName» «SecondName» «LastName»
but «SecondName» is sometimes empty and you don’t want that to leave two spaces in the output. To deal with that:
{MERGEFIELD SecondName};
depending on whether the space to be suppressed is following or before the mergefield;
the mergefield;
Note 1: the \b and \f switches don't work on Macs or in conjunction with other switches. In such cases you need to use and IF test instead, coded along the lines of-
Even so, you can use the \b and \f switches to express other mergefields that do have switches of their own. For example, suppose you have four fields ‘Product’, ‘Supplier’, ‘Quantity’ and ‘UnitPrice’, and you don’t want to output the ‘Product’, ‘Quantity’ or ‘UnitPrice’ fields if the ‘Supplier’ field is empty. In that case, you might use a field coded along the lines of:
Note 2: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac or, if you’re using a laptop, you might need to use Ctrl-Fn-F9); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. Likewise, the chevrons (i.e. '« »') are part of the actual mergefields - which you can insert from the 'Insert Merge Field' dropdown (i.e. you can't type or copy & paste them from this message, either). The spaces represented in the field constructions are all required. Instead of the →, ↵ and ¶ symbols, you should use real tabs and line/paragraph breaks, respectively.
For more Mailmerge Tips & Tricks, see: https://www.msofficeforums.com/mail-merge/21803-mailmerge-tips-tricks.html