tags:

views:

135

answers:

3

when i insert '\r\n' into a cell of a table in word document using c# ,it does not work ,why ? how to do it ?

A: 

Word.Application wordApp; Word.Document wordDoc; filePath = @"" + strWorkPath + @"Uploads\Template\template.doc"; saveFilePath = @"" + strWorkPath + @"Uploads\" + VersionStr + @"\" + fileName; object format = Word.WdSaveFormat.wdFormatDocument; wordApp = new Word.Application(); Object nothing = Missing.Value; wordDoc = wordApp.Documents.Open(ref filePath, ref nothing, ref nothing, ref nothing, ref nothing,ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing); Word.Table table = wordDoc.Tables[1]; table.Cell(1, 1).Range.Text = "sdsdlkfjdslk \r\n slkdfjslj"; as shown in the last line.

In the document, it is "sdsdlkfjdslk \r\n slkdfjslj" not "sdsdlkfjdslk slkdfjslj" can anyone help me ?

Charles
A: 

Try

"sdsdlkfjdslk" + (char)11 + "slkdfjslj" 

or

"sdsdlkfjdslk \v slkdfjslj"
SLC