1
將自定義字符串轉換爲Word表格時,無法找到將多行代碼轉換爲單個表格單元格的方法。 基本上我想在單元格中有一個軟返回來顯示同一單元格中的兩個項目。如何在使用Word時在表格單元格中獲得兩行代碼.ConvertToTable
這些字符串是外部生成的,沒有固定的單元格應該使用多行。
測試:
string testTable = "[email protected]@[email protected]";
testTable = testTable + "1/07/[email protected]@[email protected]";
testTable = testTable + "2/07/[email protected]|[email protected]@";
testTable = testTable + "3/07/[email protected]@789";
object missing = System.Reflection.Missing.Value;
object oSeperator = "@";
object oNumColumns = 3;
object oNumRows = 3;
object oApplyBorders = true;
object oApplyTrue = true;
object oApplyFalse = false;
object oFormat = Word.WdTableFormat.wdTableFormatGrid3;
object oAutoFit = false;
Word.Table MyTable = selection.ConvertToTable(ref oSeperator, ref oNumRows, ref oNumColumns, missing, ref oFormat, ref oApplyBorders, missing, missing, missing, ref oApplyFalse, missing, missing,
missing, ref oAutoFit, missing, missing);
ConvertToTable應該創建一個表,其中test2的和test2bis是在不同線路同一小區。通過使用shift-enter或在單元格中輸入來創建表格後,您可以輕鬆地手動進行操作。
我試過替換'|' '\ p','\ l'或'\ n',但所有選項都將test2bis移動到下一個表格的第一列。使用'^ p'或'\ u2028'只是將其作爲文本添加。
希望我錯過了一些東西,這可以通過在字符串中輸入正確的字符來自動完成。我看到的唯一的其他選項是在表創建完成後再次循環所有單元格,然後嘗試插入軟返回,但這會使其非常複雜。