M
Mystery Man
We use Word 2000 and 2003 automation from C# (via interop). We create
tables dynamically. However, we now need to have embedded returns
within a cell.
For example:-
Row 1: Date Text
Row 2: 1/1/2002 Help me
please
Row 3: 1/1/2004 Help me
Sample code is as follows:-
object rows = 3;
object columns = 3;
string text = "Date\tText\t1/1/2002\tHelp me\nplease\t1/1/2004\tHelp
me";
Word.Range range = _wordApp.Selection.Range;
range.Text = tableValue.ToString();
Word.Table newTable = range.ConvertToTable(ref sep // Separator
,ref numRows // NumRows
,ref numColumns // NumColumns
,ref oMissing // InitialColumnWidth
,ref oMissing // Format
,ref oMissing // ApplyBorders
,ref oMissing // ApplyShading
,ref oMissing // ApplyFont
,ref oMissing // ApplyColor
,ref oMissing // ApplyHeadingRows
,ref oMissing // ApplyLastRow
,ref oMissing // ApplyFirstColumn
,ref oMissing // ApplyLastColumn
,ref oMissing // AutoFit
,ref oMissing // AutoFitBehaviour
,ref oMissing // DefaultTableBehaviour
);
However, what this does is create a new row when it encounters the \n.
I have tried using different column separators and a few other
possibilities but to no avail.
tables dynamically. However, we now need to have embedded returns
within a cell.
For example:-
Row 1: Date Text
Row 2: 1/1/2002 Help me
please
Row 3: 1/1/2004 Help me
Sample code is as follows:-
object rows = 3;
object columns = 3;
string text = "Date\tText\t1/1/2002\tHelp me\nplease\t1/1/2004\tHelp
me";
Word.Range range = _wordApp.Selection.Range;
range.Text = tableValue.ToString();
Word.Table newTable = range.ConvertToTable(ref sep // Separator
,ref numRows // NumRows
,ref numColumns // NumColumns
,ref oMissing // InitialColumnWidth
,ref oMissing // Format
,ref oMissing // ApplyBorders
,ref oMissing // ApplyShading
,ref oMissing // ApplyFont
,ref oMissing // ApplyColor
,ref oMissing // ApplyHeadingRows
,ref oMissing // ApplyLastRow
,ref oMissing // ApplyFirstColumn
,ref oMissing // ApplyLastColumn
,ref oMissing // AutoFit
,ref oMissing // AutoFitBehaviour
,ref oMissing // DefaultTableBehaviour
);
However, what this does is create a new row when it encounters the \n.
I have tried using different column separators and a few other
possibilities but to no avail.