如何将html转换成文字,将html转换为文字

我使用docx.dll将html转换为word。但不能转换html标签。例如:HTML是一种p与将html转换为文字

adfa à asdf asdf

所以,当转换完成后,Word文件的内容是相同的

adfa à asdf asdf

我下面

[System.Web.Services.WebMethod]

public static void eprt_tml(int ptcn_id)

{

DataTable tml_tbl = DBclass.TruyVanTraVeTable1("select course_id, vname, vcontent from testimonial where contact_id='" + ptcn_id + "'");

string course_name = DBclass.TruyVanTraVeGiaTri("select vname from course where id='"+tml_tbl.Rows[0]["course_id"]+"'");

DataTable ptcn_tbl = DBclass.TruyVanTraVeTable1("select first_name, last_name, salutation_id, title from contact where id='"+ptcn_id+"'");

string ptcn_name = ptcn_tbl.Rows[0]["last_name"].ToString() + " " + ptcn_tbl.Rows[0]["first_name"].ToString();

DocX g_document;

try

{

// Store a global reference to the loaded document.

g_document = DocX.Load(@"D:\Project\CRM1\tml\tml_tpt.docx");

/*

* The template 'InvoiceTemplate.docx' does exist,

* so lets use it to create an invoice for a factitious company

* called "The Happy Builder" and store a global reference it.

*/

g_document = crt_from_tpl(DocX.Load(@"D:\Project\CRM1\tml\tml_tpt.docx"), course_name, tml_tbl.Rows[0]["vname"].ToString(), tml_tbl.Rows[0]["vcontent"].ToString(), ptcn_name, ptcn_tbl.Rows[0]["title"].ToString());

// Save all changes made to this template as Invoice_The_Happy_Builder.docx (We don't want to replace InvoiceTemplate.docx).

g_document.SaveAs(@"D:\Project\CRM1\tml\Invoice_The_Happy_Builder.docx");

}

// The template 'InvoiceTemplate.docx' does not exist, so create it.

catch (FileNotFoundException)

{

}

}

//Create tml from template

[System.Web.Services.WebMethod]

private static DocX crt_from_tpl(DocX template, string course_name, string vname, string vcontent, string ptcn_name, string ptcn_title)

{

template.AddCustomProperty(new CustomProperty("static_title", "Ứng Dụng Thực Tiễn Thành Công"));

template.AddCustomProperty(new CustomProperty("tmlname", vname));

template.AddCustomProperty(new CustomProperty("tmlcontent", vcontent));

template.AddCustomProperty(new CustomProperty("ptcnname", ptcn_name));

template.AddCustomProperty(new CustomProperty("ptcntitle", ptcn_title));

template.AddCustomProperty(new CustomProperty("coursename", course_name));

return template;

}

码我怎样才能解决这个问题?

2012-02-06

Hainlp

+0

感谢ParPar,但我的代码仍然运行良好,我只想替换或删除html标记。有任何工具可以做到这一点? –

2012-02-06 16:04:03

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值