I have a complex issue at hand.
I have developed a program that takes some information from a database and inserts it in a word document. After doing so, it saves the word document on the server and the program user can download the autofilled document.
I use the class Microsoft.Office.Interop.Word to solve this task but it is more than impossible to get this working on a x64 server or a x64 workstation.
Is there ANY other way to accomplish this task? I need the file to be able to be opened in Word. I don’t care if it was generated from say OpenOffice or something like that.
Anyone know a solution for this issue not using the Interop.Word class?
UPDATE (solution):
Here is what I ended up doing:
I saved the wordfile I wanted to use as a template as an XML file.
Then I use this little function:
public void TestEditContract(string path)
{
XmlDocument document = new XmlDocument();
TextReader reader = File.OpenText(path + "\\wordfile.xml");
string allxml = reader.ReadToEnd();
reader.Close();
allxml = allxml.Replace("placeholder1", "Some content");
document.LoadXml(allxml);
document.Save(path + "\\wordfile.doc");
}
In the end I simply save it as a .doc file and it works like a charm 🙂
This is a little hack’ish but it works very well and is server independent. Thank you cgcarter1 for pointing me in the right direction.
You kind of have a cadillac going when you need a sportster. Why save the document to the server when you can just hand it to them through the buffer stream? Here is a very good method of delivering an exported Word Doc through the buffer without any dependents:
http://geekswithblogs.net/vivek/archive/2006/09/26/92316.aspx
Without dependents, there is no need to worry about the architecture of the server. Also, you are not giving access to your file structure to the asp.net user when you serve the file through the buffer so it is a little more secure.