पर पैराग्राफ स्टाइल (हेडिंग 1, हेडिंग 2, हेड 3 आदि) जोड़ें, क्या कोई मुझे ओपन एक्सएमएल वर्ड प्रोसेसिंग का उपयोग करके पैराग्राफ पर पूर्वनिर्धारित शैलियों को जोड़ने का मार्गदर्शन कर सकता है? मैंने मंचों पर उपलब्ध विभिन्न समाधानों की कोशिश की है लेकिन मेरे लिए कुछ भी काम नहीं करता है। यहां मैं यह पूरा करना चाहता हूं:ओपनएक्सएमएल एक वर्ड प्रोसेसिंग दस्तावेज़
// 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 StyleDefinitionsPart होना चाहिए –