當我使用c#插入'\r\n'
到word文檔中的表格單元格時,它不起作用,爲什麼?怎麼做 ?如何在Word中的表格單元格中插入換行符?
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";
如最後一行所示。
在該文件中,它是"sdsdlkfjdslk \r\n slkdfjslj"
,不"sdsdlkfjdslk slkdfjslj"
+1這對我來說訣竅 – 2013-03-26 17:43:32
對我來說,它會失敗,但有以下例外:'\ v',十六進制值0x0B,是一個無效字符。 – 2016-10-07 10:32:19