diff --git a/ETS_Data/officeXmlMan.cs b/ETS_Data/officeXmlMan.cs new file mode 100644 index 0000000..b16e9b6 --- /dev/null +++ b/ETS_Data/officeXmlMan.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using System.Text.RegularExpressions; +using DocumentFormat.OpenXml.Packaging; + +namespace ETS_Data +{ + /// + /// gestioen documetni office/xml + /// + public class officeXmlMan + { + /// + /// fa sostituzioni di testo in un doc .docx + /// + /// + /// + /// + public static void replaceDocxText(string fullPathFile,string textOrig, string textNew) + { + using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(fullPathFile, true)) + { + using (StreamReader sr = new StreamReader(wordDoc.MainDocumentPart.GetStream())) + { + string docText = sr.ReadToEnd(); + Regex regexText = new Regex(textOrig); + docText = regexText.Replace(docText, textNew); + } + } + } + + + } +}