そのため、XML 経由の入力を受け入れるいくつかのプレーン テキスト形式 (リッチ テキスト形式も試しました) コントロールを備えた Microsoft Word 2007 ドキュメントがあります。
キャリッジ リターンの場合、キャリッジ リターンが必要なときに "\r\n" を含む文字列を XML 経由で渡しましたが、Word ドキュメントはそれを無視し、同じ行に折り返し続けました。また、C# マッパーで \r\n を System.Environment.NewLine に置き換えようとしましたが、とにかく \r\n を挿入しただけで、まだ機能しませんでした。
また、コントロール自体では、コントロールのプロパティで「キャリッジ リターン (複数のパラグラフ) を許可する」に設定していることにも注意してください。
これは 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) で改行文字の無視をやめる方法を知っている人はいますか??