Hi ,
I am unable to write into the document using the open xml sdk 2.0 in Axapata 2009. Here it is sample code am using it to create and write into the document.
DocumentFormat.OpenXml.Packaging.WordprocessingDocument wordPackage = null;
DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart = null;
DocumentFormat.OpenXml.Wordprocessing.Document document = null;
DocumentFormat.OpenXml.Wordprocessing.Body body = null;
DocumentFormat.OpenXml.Wordprocessing.Paragraph paragraph = null;
DocumentFormat.OpenXml.Wordprocessing.Text text = new DocumentFormat.OpenXml.Wordprocessing.Text("Hello world!");
DocumentFormat.OpenXml.Wordprocessing.Run run = new DocumentFormat.OpenXml.Wordprocessing.Run(text);
;
wordPackage = DocumentFormat.OpenXml.Packaging.WordprocessingDocument::Create(@"C:\TestDocByAppend.docx", DocumentFormat.OpenXml.WordprocessingDocumentType::Document);
mainDocumentPart = wordPackage.AddMainDocumentPart();
document = new DocumentFormat.OpenXml.Wordprocessing.Document();
body = new DocumentFormat.OpenXml.Wordprocessing.Body();
paragraph = new DocumentFormat.OpenXml.Wordprocessing.Paragraph();
paragraph.Append(run);
body.Append(paragraph);
document.Append(body);
document.Save(mainDocumentPart);
wordPackage.Close();
The above code just creates the blank document but does not write the text in it. This code works perfectly in the .Net using the visual studio which creates and writes the text in the document. The open xml dll used for both .Net and Axapta is same. Can you please help me out in how to do this Axapta.? Thanks
*This post is locked for comments
I have the same question (0)