Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Oct 30, 2014 9:28 am

Hey you nice program.

First of all, Nice program.

I have a question regarding linebreake after a paragraph. Is this possible so you can do this in a loop?


What i am trying to do is

For i = 1 To 5
'Append Text
paragraph_Renamed.AppendText("Hello World!")
Next

Result: Hello World!Hello World!Hello World!Hello World!Hello World!

What I want:

Hello World!
Hello World!
Hello World!
Hello World!
Hello World!

Anyone that can help me?

janusmaack
 
Posts: 5
Joined: Thu Oct 30, 2014 8:17 am

Thu Oct 30, 2014 9:36 am

Hello,

Thanks for your inquiry.
Please try the following code:
Code: Select all
 Document document = new Document();
            Section section = document.AddSection();
         
            for (int i = 0; i < 5; i++)
            {
                Paragraph p = section.AddParagraph();
                p.AppendText("Hello World!");
            }
            document.SaveToFile("sample.docx",FileFormat.Docx);
            System.Diagnostics.Process.Start("sample.docx");


Best wishes,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Thu Oct 30, 2014 9:38 am

I properbly should have sayd that i am using VB.NET. Is it the same code?

Thanks for the quick reply!! :)

janusmaack
 
Posts: 5
Joined: Thu Oct 30, 2014 8:17 am

Thu Oct 30, 2014 9:42 am

Hello,

Attached VB.net code.
Code: Select all
Dim document As New Document()
Dim section As Section = document.AddSection()

For i As Integer = 0 To 4
   Dim p As Paragraph = section.AddParagraph()
   p.AppendText("Hello World!")
Next
document.SaveToFile("sample.docx", FileFormat.Docx)
System.Diagnostics.Process.Start("sample.docx")


Best wishes,
Amy
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Thu Oct 30, 2014 1:34 pm

Thank you very much!

janusmaack
 
Posts: 5
Joined: Thu Oct 30, 2014 8:17 am

Fri Oct 31, 2014 1:34 am

Hello,

Have a nice day. Please don't hesitate to contact us if you have any problems.

Best wishes,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc