Posted: 12/13/2010
Hi all I would like to help me with this ..... I'm in a project where I need to send a string of html and open it with office word anyone know how with asp.net?
string strCadena = "<html><head></head><body><table><tr><td>1</td></tr></table></body></html>";
Sorry about my english .... one thing else .... the company don´t want to pay for a component :(
Posted: 12/14/2010
This can help you HTML to Word C# component version 4.1.7 released!
I think the Raghav's answer is the right choice.
However, I've found the following discussion in asp.net forums: http://forums.asp.net/p/1224223/4070156.aspx which might be also helpful.
Following code is very simple code for Create word file with html .
using System.IO;
public void CreateWordFile(string Filename)
{
string FilePath = Server.MapPath("~")+ Filename + ".doc";
if (File.Exists(PdfFilePath) == false) { FileStream fs = File.Create(FilePath); fs.Close(); }
string strCadena = "<table><tr><td>1</td></tr></table>";
File.WriteAllText(FilePath, "<div>" + strCadena + "</div>");
}
Enjoy....
eflorespalma said:user="Edgar Flores Palma"]Hi all I would like to help me with this ..... I'm in a project where I need to send a string of html and open it with office word anyone know how with asp.net? string strCadena = "<html><head></head><body><table><tr><td>1</td></tr></table></body></html>";Sorry about my english .... one thing else .... the company don´t want to pay for a component :(
user="Edgar Flores Palma"]
Yeah i saw that component, but the company don´t want to pay nothing at all :( What a shame !!! thank u !!
This doesn´t work i tried it !!! and just copy the string, because if u want to see you have to open it with html view
Posted: 12/15/2010
I don't understand what you want to say but this code is create word file with html.
Chek this file in c derive and open then it will show only 1 not all string .I hope it will be usefull for you .
Chek this file in c derive and open then it will show only 1 not all string .
I hope it will be usefull for you .
string FilePath = "C:\\11.doc";
if (File.Exists(FilePath) == false){
FileStream fs = File.Create(FilePath);fs.Close();}
fs.Close();
File.WriteAllText(FilePath, "<div>" + strCadena + "</div>"
);
viswas_shende said: user="vishvas shende"]I don't understand what you want to say but this code is create word file with html. Chek this file in c derive and open then it will show only 1 not all string .I hope it will be usefull for you . string FilePath = "C:\\11.doc";if (File.Exists(FilePath) == false){ FileStream fs = File.Create(FilePath);fs.Close();} string strCadena = "<table><tr><td>1</td></tr></table>"; File.WriteAllText(FilePath, "<div>" + strCadena + "</div>");
user="vishvas shende"]
if (File.Exists(FilePath) == false)
FileStream fs = File.Create(FilePath);
Yes it creates a word document... , but when i try to open it ... office suggest me to open with html view and not the normal way !