Last post Feb 24, 2020 03:44 PM by jonnygareth30
Jul 24, 2019 02:10 PM|jonnygareth30|LINK
I am using an on click event to open Word documents within my asp.net C# application but I would also like to replace text within the Word Document when opened using a SessionData value which stores the company name from within my C# code. for example I
would like the text within the header to be replaced with the company name as multiple companies will be accessing the same documents. The Word documents are stored within my database as a Varbinary(MAX) value. I am unsure how to do this or if it is even possible.
Any assistance would be greatly appreciated.
Jul 25, 2019 06:29 AM|samwu|LINK
replace text within the Word Document when opened using a SessionData value which stores the company name from within my C# code
According to your description, I couldn’t understand your requirement clearly.
Do you mean you want to Replacing Text in word Document? If this is your requirement, I suggest you try to use Spire.Doc to Replace Text on Document.
protected void Button1_Click(object sender, EventArgs e)
Document doc = new Document();
doc.Replace("1", "2", true, true);
Jul 25, 2019 12:26 PM|AddWeb Solution|LINK
I am providing you some link regarding this it will help you
Feb 24, 2020 03:44 PM|jonnygareth30|LINK
Thank you very much for your responses and please accept my apologies for the delay in my response. I have been away from the project for a while.
Is it possible to change text on multiple documents? (e.g. not specify it to 1 document name as below)
For example when pulling the folder where my documents are stored it pulls multiple documents, please see below my code which populates a Gridview:
string filePaths = Directory.GetFiles(Server.MapPath("~/Documents/Templates/"));
List<ListItem> files = new List<ListItem>();
foreach (string filePath in filePaths)
files.Add(new ListItem(Path.GetFileName(filePath), filePath));
GV.DataSource = files;
Please see my code to download which runs when the "Download" button is clicked:
protected void DownloadCrownfordForm(object sender, EventArgs e)
string filePath = (sender as LinkButton).CommandArgument;
Response.ContentType = ContentType;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(filePath));
Within the Word documents I have text as "Ccc" which is what i would like to replace with text populated within a textbox. Would this be possible?
Many thanks in advance for any help, it is greatly appreciated.