Open kkurhekar10 opened 1 year ago
@kkurhekar10, please provide the relevant parts of your code, eg., in the form of a unit test, and the Open XML markup (e.g, a Word document) so that we can reproduce the behavior.
File.docx Attached is the sample source file, output file and code snippet. static void Main(string[] args) { File_Output.docx
string filepath = "C:/Sample/";
string Filename = "File.docx";
string SrcFilename = filepath + Filename;
string DstFilename = @"C:\Sample\" + "File" + "_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss") + ".docx"; File.Copy(SrcFilename, DstFilename, true); if (System.IO.File.Exists(DstFilename))
{
using (WordprocessingDocument wDoc = WordprocessingDocument.Open(DstFilename, true))
{
if (wDoc != null)
{
XDocument xDoc = wDoc.MainDocumentPart.GetXDocument();
if (xDoc != null)
{
string User = "user1"; IEnumerable
Couple thoughts and questions:
@kkurhekar10, could you please test your code with a different replacement text that does not contain any characters that are reserved in XML? For example, use "TEST".
We are doing some String manipulation in our code using OPEN XML and Facing issue. Text In Input File : “Figure 4. Word and other agencies like IRCC look this for strategy and technical solutions. “ Text in output File after manipulation: “Figure 4. Word and other agencies l<> IRCC look this for strategy and technical solutions.”
Here IRCC should be replace with <>, but “ike” is getting replaced instead.
Figure 4 is a link here to some figure. When read in Open XML , it is read as REF _Ref12123123