You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use attached document? or create new document then write text "Text1" in the document and create textbox with text "TextBox2".
Replace text like in the following code example:
XWPFDocument document;
using (var fs = new FileStream(@"D:\DOCUMENTS\PROGRMG\dotnet\Stomatient\Stomatient\DocumentTemplates\0\textbox.docx", FileMode.Open))
{
using (var ms = new MemoryStream())
{
fs.CopyTo(ms);
ms.Position = 0;
document = new XWPFDocument(ms);
}
}
document.FindAndReplaceText("Text1", "Replace1");
document.FindAndReplaceText("TextBox2", "Replace2");
var tempFile = Path.GetTempFileName() + ".docx";
using (var fs = new FileStream(tempFile, FileMode.CreateNew))
{
document.Write(fs);
fs.Close();
}
document.Close();
document.Dispose();
var psi = new ProcessStartInfo(tempFile);
psi.Verb = "ViewProtected";
Process.Start(psi);
Issue Description
"Text1" is replaced, but "TextBox2" inside textbox is not replaced.
And there is no any way to access text in the text box.
For example with DocX library textbox xan be accessed using Paragraphs, but here it seems it's not possible.
There is an answer on the SO but for Java how to access - https://stackoverflow.com/questions/46802369/replace-text-in-text-box-of-docx-by-using-apache-poi/46894499#46894499 - but it's very ugly and there is no Cursor in .NET's GetCTP() and no SelectPath() I could find.
The text was updated successfully, but these errors were encountered:
NPOI Version
2.7.2
File Type
Upload the Word File
textbox.docx
Reproduce Steps
Issue Description
"Text1" is replaced, but "TextBox2" inside textbox is not replaced.
And there is no any way to access text in the text box.
For example with DocX library textbox xan be accessed using Paragraphs, but here it seems it's not possible.
There is an answer on the SO but for Java how to access - https://stackoverflow.com/questions/46802369/replace-text-in-text-box-of-docx-by-using-apache-poi/46894499#46894499 - but it's very ugly and there is no Cursor in .NET's GetCTP() and no SelectPath() I could find.
The text was updated successfully, but these errors were encountered: