For this we have to do some exercise like as follows :
1. Create a word documents
2. Insert all the styles like in image.
3. Save the document.
4. Rename the document(DocName.docx to DocName.zip)
5. Extract the document.
6. Go to DocName\Word folder
7. Copy the styles.xml and paste in the solution.
8. Write the below code to use in our solution
StyleDefinitionsPart styleDefinitionsPart = mainPart.AddNewPart
//File Styles Uploading : Location of style c:\\styles.xml
FileStream stylesTemplate = new FileStream("c:\\styles.xml", FileMode.Open, FileAccess.Read);
styleDefinitionsPart.FeedData(stylesTemplate);
styleDefinitionsPart.Styles.Save();
9. When we want to append Heading 1 with our para then we can use like :
Paragraph AuthorPara = new Paragraph();
Run run = new Run();
Text TextLine = new Text("Created by: " + System.Environment.UserName);
run4.Append(TextLine);
AuthorPara.Append(new ParagraphProperties (new ParagraphStyleId (){Val="Heading1"}), run);
This is the way we can append styles to our created document.
Does it work if i change my fonts in Word?
ReplyDeleteWell for the change in the font, you just have to update the styles.xml file.
ReplyDeletestyle.xml file have all the current styles of the document.
how to export info path form in excel on button click when it is upload in share point 2010
ReplyDeletesorry i'd'nt know
Delete