2016-09-21 20 views
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); 

Example manually altered table

ConvertToTable应该创建一个表,其中test2的和test2bis是在不同线路同一小区。通过使用shift-enter或在单元格中输入来创建表格后,您可以轻松地手动进行操作。

我试过替换'|' '\ p','\ l'或'\ n',但所有选项都将test2bis移动到下一个表格的第一列。使用'^ p'或'\ u2028'只是将其作为文本添加。

希望我错过了一些东西,这可以通过在字符串中输入正确的字符来自动完成。我看到的唯一的其他选项是在表创建完成后再次循环所有单元格,然后尝试插入软返回,但这会使其非常复杂。

回答

相关问题