Qualcuno può guidarmi come aggiungere stili predefiniti sul paragrafo utilizzando l'Elaborazione testo XML aperta? Ho provato varie soluzioni disponibili nei forum ma nulla funziona per me. Ecco cosa voglio ottenere:OpenXML Aggiunge lo stile di paragrafo (Titolo1, Titolo2, Testa 3 ecc.) Ad un documento di elaborazione testo
// Create a document by supplying the filepath.
WordprocessingDocument wordDocument = WordprocessingDocument.Create("E:/Test/Executive.Docx", WordprocessingDocumentType.Document);
// Add a main document part.
MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
// Create the document structure and add some text.
mainPart.Document = new Document();
Body body = mainPart.Document.AppendChild(new Body());
Paragraph para = body.AppendChild(new Paragraph());
Run run = para.AppendChild(new Run());
run.AppendChild(new Text("Executive Summary"));
if (para.Elements<ParagraphProperties>().Count() == 0)
para.PrependChild<ParagraphProperties>(new ParagraphProperties());
// Get the ParagraphProperties element of the paragraph.
ParagraphProperties pPr = para.Elements<ParagraphProperties>().First();
// Set the value of ParagraphStyleId to "Heading3".
pPr.ParagraphStyleId = new ParagraphStyleId() { Val = "Heading1" };
StyleDefinitionPart deve essere StyleDefinitionsPart –