using (WordprocessingDocument doc = WordprocessingDocument.Open(genericPathFolder + @"\" + "TESTR.docx", true)) { //Find the first table in the document. Table table = doc.MainDocumentPart.Document.Body.Elements<Table>().First(); for (int i = 0; i < 100; i++) { TableRow row = table.Elements<TableRow>().ElementAt(i); for (int j = 0; j < 5; j++) { TableCell cell = row.Elements<TableCell>().ElementAt(j); RunProperties runProp = new RunProperties(); // Создаем run RunFonts runFont = new RunFonts(); // Создаем шрифт для run FontSize size = new FontSize(); // Шрифт размер runFont.Ascii = "ArialNarrow"; // шрифт size.Val = new StringValue("24"); // размер = 24/2 = 12й шрифт runProp.Append(runFont); runProp.Append(size); if (j == 1) { Run run = new Run(new Text("123")); run.PrependChild<RunProperties>(runProp); cell.PrependChild(new Paragraph(run)); } if (j == 2) { Run run = new Run(new Text("OLOLOLOLOLOLO")); run.PrependChild<RunProperties>(runProp); cell.PrependChild(new Paragraph(run)); } if (j == 3) { Run run = new Run(new Text("789")); run.PrependChild<RunProperties>(runProp); cell.PrependChild(new Paragraph(run)); } } } } 

I fill the table with text, but for some reason, the text in each cell is preceded by an indent. enter image description here

  • What is this indent if you open a file in Word? - Qwertiy
  • That’s it, which is not at all clear. If I open the file in Word and turn on "show all signs", then this indent is not displayed. However, if you place the cursor in front of the text and press backspace, then the text takes the normal position, close to the left border of the table. - Darron
  • one
    So maybe this is the standard indent of the first line? 1.25 cm, sort of. See paragraph properties - qzavyer
  • If this was the answer, then I could mark it as true! ^^ Thanks, this is it! - Darron

0