因此,我有一个 Microsoft Word 2007 文档,其中包含几个纯文本格式(我也尝试过富文本格式)控件,这些控件通过 XML 接受输入。
对于回车,当我想要回车时,我通过包含 "\r\n" 的 XML 传递了字符串,但是 word 文档忽略了这一点,只是将内容包装在同一行。我还尝试在我的 C# 映射器中将 \r\n 替换为 System.Environment.NewLine ,但无论如何都放入了 \r\n ,但这仍然不起作用。
另请注意,在控件本身上,我已在控件属性中将其设置为“允许回车(多个 Paragrpahs)”。
这是 listMapper 的 XML
<Field id="32" name="32" fieldType="SimpleText">
<DataSelector path="/Data/DB/DebtProduct">
<InputField fieldType=""
path="/Data/DB/Client/strClientFirm"
link="" type=""/>
<InputField fieldType=""
path="strClientRefDebt"
link="" type=""/>
</DataSelector>
<DataMapper formatString="{0} Account Number: {1}"
name="SimpleListMapper" type="">
<MapperData></MapperData>
</DataMapper>
</Field>
请注意,这是我实际映射列表的 listMapper C#(注意我尝试附加 system.environment.newline 的位置)
namespace DocEngine.Core.DataMappers
{
public class CSimpleListMapper:CBaseDataMapper
{
public override void Fill(DocEngine.Core.Interfaces.Document.IControl control, CDataSelector dataSelector)
{
if (control != null && dataSelector != null)
{
ISimpleTextControl textControl = (ISimpleTextControl)control;
IContent content = textControl.CreateContent();
CInputFieldCollection fileds = dataSelector.Read(Context);
StringBuilder builder = new StringBuilder();
if (fileds != null)
{
foreach (List<string> lst in fileds)
{
if (CanMap(lst) == false) continue;
if (builder.Length > 0 && lst[0].Length > 0)
builder.Append(Environment.NewLine);
if (string.IsNullOrEmpty(FormatString))
builder.Append(lst[0]);
else
builder.Append(string.Format(FormatString, lst.ToArray()));
}
content.Value = builder.ToString();
textControl.Content = content;
applyRules(control, null);
}
}
}
}
}
有没有人知道如何让 MS Word 2007 (docx) 退出忽略我的换行符?