We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

I have a string, which will be inserted into a word file

I have a string(which is inside a solution/DLL which does not have syncfusion's DLLs), and I will insert that string into a word file(later in a project with syncfusions dlls included).

Project without Syncfusion:
string bla="Text some text"+Environment.NewLine+"more text"+Environment.NewLine;

Project with Syncfusion, inserted into a word file that string, but I get no line breaks.

How ?


4 Replies

PE Priyanga Elangovan Syncfusion Team September 23, 2016 09:01 AM UTC

Hi Customer,

Thank you for contacting Syncfusion support.

DocIO provides support to insert a linebreak to the paragraph using AppendBreak API. For your reference please find the following code snippet.


 
//Loads the template document
WordDocument wordDocument = new WordDocument();
wordDocument.EnsureMinimal();
//Adds the paragraph to the document
WParagraph paragarph = wordDocument.LastSection.AddParagraph() as WParagraph;
//Appends the text to the paragraph
paragarph.AppendText(
"Text some text");
//Appends the line break
paragarph.AppendBreak(
BreakType.LineBreak);
//Appends the text to the paragraph
paragarph.AppendText(
"more text");
//Appends the line break
paragarph.AppendBreak(
BreakType.LineBreak);
//Saves the document
wordDocument.Save(
"output.docx");
wordDocument.Close();
 

Regards,
Priyanga.E
 



PE Priyanga Elangovan Syncfusion Team September 23, 2016 09:52 AM UTC

Hi Customer,

Kindly ignore our previous update.

Regarding “
string bla="Text some text"+Environment.NewLine+"more text"+Environment.NewLine”:
As per Microsoft Word behaviour, the functionality of Environment.NewLine character is to split the content as new paragraph and DocIO does the same.

Kindly use the AppendBreak API to insert the line break to the paragraph. For your reference please find the following code snippet.
 
//Loads the template document
WordDocument wordDocument = new WordDocument();
wordDocument.EnsureMinimal();
//Adds the paragraph to the document
WParagraph paragarph = wordDocument.LastSection.AddParagraph() as WParagraph;
//Appends the text to the paragraph
paragarph.AppendText(
"Text some text");
//Appends the line break
paragarph.AppendBreak(
BreakType.LineBreak);
//Appends the text to the paragraph
paragarph.AppendText(
"more text");
//Appends the line break
paragarph.AppendBreak(
BreakType.LineBreak);
//Saves the document
wordDocument.Save(
"output.docx");
wordDocument.Close();
 
 

Regards,
Priyanga.E
 


  



TE Testname September 27, 2016 07:08 AM UTC

The problem at this point is, that I do not have any syncfusion library.


SY Sethumanikkam Yogendran Syncfusion Team September 28, 2016 05:38 AM UTC

Hi Customer,

Thank you for your update.

You can download the latest version Essential studio 14.2.0.32 service pack from below link.
https://www.syncfusion.com/forums/125638/essential-studio-2016-volume-2-service-pack-release-v14-2-0-32-available-for-download

Please refer the below link to know more about release announcements.
https://www.syncfusion.com/forums/announcements

Please refer the below link to know more about assemblies required for DocIO.
https://help.syncfusion.com/file-formats/docio/assemblies-required

You may also contact salessupport@syncfusion.com for further clarification.

Please let us know if you have any other questions.

Thanks,
Sethumanikkam.Y
 


Loader.
Live Chat Icon For mobile
Up arrow icon