lorsque j'insère '\r\n'
dans une cellule d'une table dans un document Word en utilisant C#, cela ne fonctionne pas, pourquoi? comment faire ?Comment insérer une nouvelle ligne dans une cellule de tableau dans 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";
comme indiqué dans la dernière ligne.
Dans le document, il est "sdsdlkfjdslk \r\n slkdfjslj"
, pas "sdsdlkfjdslk slkdfjslj"
+1 Cela a fait l'affaire pour moi –
Pour moi, il échoue avec l'exception suivante: '\ v', valeur hexadécimale 0x0B, est un caractère invalide. –