Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6878891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:46:45+00:00 2026-05-27T04:46:45+00:00

My expected result is: Hello world! but when i using below codes: MainDocumentPart mainDocumentPart

  • 0

My expected result is:

  • Hello
  • world!

but when i using below codes:

        MainDocumentPart mainDocumentPart =
          package.AddMainDocumentPart();

        DocumentFormat.OpenXml.Wordprocessing.Document elementW =
          new DocumentFormat.OpenXml.Wordprocessing.Document(
            new Body(
              new DocumentFormat.OpenXml.Wordprocessing.Paragraph(
                    new NumberingProperties(
                      new NumberingLevelReference() { Val = 0 },
                      new NumberingId() { Val = 1 })
                    ),
                new Run(
                  new RunProperties(),
                  new Text("Hello, ") { Space = new DocumentFormat.OpenXml.EnumValue<DocumentFormat.OpenXml.SpaceProcessingModeValues> { InnerText = "preserve" } })),
              new DocumentFormat.OpenXml.Wordprocessing.Paragraph(
                new ParagraphProperties(
                  new NumberingProperties(
                    new NumberingLevelReference() { Val = 0 },
                    new NumberingId() { Val = 1 })),
                new Run(
                  new RunProperties(),
                  new Text("world!")
                  {
                      Space = new DocumentFormat.OpenXml.EnumValue<DocumentFormat.OpenXml.SpaceProcessingModeValues> { InnerText = "preserve" }
                  })));

        elementW.Save(mainDocumentPart);

Result is:

  1. Hello
  2. world!

How can i get my expected result?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:46:46+00:00Added an answer on May 27, 2026 at 4:46 am

    This should create you a blank document with your expected output:

            // Creates an Document instance and adds its children.
            public Document GenerateDocument()
            {
                Document document1 = new Document();
                document1.AddNamespaceDeclaration("ve", "http://schemas.openxmlformats.org/markup-compatibility/2006");
                document1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office");
                document1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
                document1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
                document1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml");
                document1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
                document1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word");
                document1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
                document1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml");
    
                Body body1 = new Body();
    
                Paragraph paragraph1 = new Paragraph(){ RsidParagraphAddition = "00AF4948", RsidParagraphProperties = "00625634", RsidRunAdditionDefault = "00625634" };
    
                ParagraphProperties paragraphProperties1 = new ParagraphProperties();
                ParagraphStyleId paragraphStyleId1 = new ParagraphStyleId(){ Val = "ListParagraph" };
    
                NumberingProperties numberingProperties1 = new NumberingProperties();
                NumberingLevelReference numberingLevelReference1 = new NumberingLevelReference(){ Val = 0 };
                NumberingId numberingId1 = new NumberingId(){ Val = 1 };
    
                numberingProperties1.Append(numberingLevelReference1);
                numberingProperties1.Append(numberingId1);
    
                paragraphProperties1.Append(paragraphStyleId1);
                paragraphProperties1.Append(numberingProperties1);
    
                Run run1 = new Run();
                Text text1 = new Text();
                text1.Text = "Hello";
    
                run1.Append(text1);
    
                paragraph1.Append(paragraphProperties1);
                paragraph1.Append(run1);
    
                Paragraph paragraph2 = new Paragraph(){ RsidParagraphAddition = "00625634", RsidParagraphProperties = "00625634", RsidRunAdditionDefault = "00625634" };
    
                ParagraphProperties paragraphProperties2 = new ParagraphProperties();
                ParagraphStyleId paragraphStyleId2 = new ParagraphStyleId(){ Val = "ListParagraph" };
    
                NumberingProperties numberingProperties2 = new NumberingProperties();
                NumberingLevelReference numberingLevelReference2 = new NumberingLevelReference(){ Val = 0 };
                NumberingId numberingId2 = new NumberingId(){ Val = 1 };
    
                numberingProperties2.Append(numberingLevelReference2);
                numberingProperties2.Append(numberingId2);
    
                paragraphProperties2.Append(paragraphStyleId2);
                paragraphProperties2.Append(numberingProperties2);
    
                Run run2 = new Run();
                Text text2 = new Text();
                text2.Text = "world!";
    
                run2.Append(text2);
    
                paragraph2.Append(paragraphProperties2);
                paragraph2.Append(run2);
    
                SectionProperties sectionProperties1 = new SectionProperties(){ RsidR = "00625634", RsidSect = "00AF4948" };
                HeaderReference headerReference1 = new HeaderReference(){ Type = HeaderFooterValues.Even, Id = "rId7" };
                HeaderReference headerReference2 = new HeaderReference(){ Type = HeaderFooterValues.Default, Id = "rId8" };
                FooterReference footerReference1 = new FooterReference(){ Type = HeaderFooterValues.Even, Id = "rId9" };
                FooterReference footerReference2 = new FooterReference(){ Type = HeaderFooterValues.Default, Id = "rId10" };
                HeaderReference headerReference3 = new HeaderReference(){ Type = HeaderFooterValues.First, Id = "rId11" };
                FooterReference footerReference3 = new FooterReference(){ Type = HeaderFooterValues.First, Id = "rId12" };
                PageSize pageSize1 = new PageSize(){ Width = (UInt32Value)12240U, Height = (UInt32Value)15840U };
                PageMargin pageMargin1 = new PageMargin(){ Top = 1440, Right = (UInt32Value)1440U, Bottom = 1440, Left = (UInt32Value)1440U, Header = (UInt32Value)720U, Footer = (UInt32Value)720U, Gutter = (UInt32Value)0U };
                Columns columns1 = new Columns(){ Space = "720" };
                DocGrid docGrid1 = new DocGrid(){ LinePitch = 360 };
    
                sectionProperties1.Append(headerReference1);
                sectionProperties1.Append(headerReference2);
                sectionProperties1.Append(footerReference1);
                sectionProperties1.Append(footerReference2);
                sectionProperties1.Append(headerReference3);
                sectionProperties1.Append(footerReference3);
                sectionProperties1.Append(pageSize1);
                sectionProperties1.Append(pageMargin1);
                sectionProperties1.Append(columns1);
                sectionProperties1.Append(docGrid1);
    
                body1.Append(paragraph1);
                body1.Append(paragraph2);
                body1.Append(sectionProperties1);
    
                document1.Append(body1);
                return document1;
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Steps: Run the build including unit tests. Expected result: the unit tests are executed
The example code of section 10.6, the expected result is: after several iterations, the
Update: I've corrected the post, so the question is closed. Expected result: Menu width
I expected A::~A() to be called in this program, but it isn't: #include <iostream>
I expected this to print [b] but it prints [] : $x = abc;
I am looking for the prototypical 'Hello World' program that creates a Mathematica Notebook
Here is the sample: Dim TestString As String = Hello, & Chr(0) & World
I'm using the following in the web page but can't get a response from
I think this example speaks for itself: http://jsfiddle.net/FLRka/1/ The expected result for me is
Can someone shed some light on this issue? The expected result does NOT appear

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.