Loading ...

How convert HTML to Word

Who is online?  0 guests and 0 members
home  »  forums   »  asp.net topics   »  getting started / general asp.net   » How convert HTML to Word

How convert HTML to Word

Posts under the topic: How convert HTML to Word

Posted: 12/13/2010

Lurker 97  points  Lurker
  • Joined on: 10/25/2010
  • Posts: 7

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

Guru 16813  points  Guru
  • Joined on: 4/19/2009
  • Posts: 490
  Answered

Posted: 12/14/2010

Professional 8505  points  Professional
  • Joined on: 5/3/2010
  • Posts: 391
  Answered

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.


Posted: 12/14/2010

Lurker 15  points  Lurker
  • Joined on: 12/14/2010
  • Posts: 3

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....



 


Posted: 12/14/2010

Lurker 15  points  Lurker
  • Joined on: 12/14/2010
  • Posts: 3

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 :( 

 

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....



 


Posted: 12/14/2010

Lurker 97  points  Lurker
  • Joined on: 10/25/2010
  • Posts: 7

Yeah i saw that component, but the company don´t want to pay nothing at all :( What a shame !!! thank u !!


Posted: 12/14/2010

Lurker 97  points  Lurker
  • Joined on: 10/25/2010
  • Posts: 7

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

Lurker 15  points  Lurker
  • Joined on: 12/14/2010
  • Posts: 3

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>"

);


Posted: 12/15/2010

Lurker 97  points  Lurker
  • Joined on: 10/25/2010
  • Posts: 7

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>"

);

 

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 !


Page 1 of 1 (9 items)