jeudi 26 mars 2015

Write data into TextInput elements in docx documents with OpenXML 2.5


Vote count:

0




I have some docx documents. I read them with OpenXML 2.5 SDK and I search for the TextInputs in each doc.



byte[] filebytes = System.IO.File.ReadAllBytes("Test.docx");

using (MemoryStream stream = new MemoryStream(filebytes))
using (WordprocessingDocument wordDocument = WordprocessingDocument.Open(stream, true))
{

IEnumerable<FormFieldData> fields = wordDocument.MainDocumentPart.Document.Descendants<FormFieldData>();
foreach (var field in fields)
{

IEnumerable<TextInput> textInputs = field.Descendants<TextInput>();
foreach (var ti in textInputs)
{
<<HERE>>
}
}

wordDocument.MainDocumentPart.Document.Save();

stream.Flush();
ETC...
}


How could I write a value into each TextInput ?


Thanks!



asked 16 secs ago







Write data into TextInput elements in docx documents with OpenXML 2.5

Aucun commentaire:

Enregistrer un commentaire