将HTML转换成字 [英] Convert html to word
本文介绍了将HTML转换成字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用docx.dll将HTML转换成字。但不能转换html标记。例如:HTML是一种 P
与
I use docx.dll to convert html to word. But can't convert html tag. For example : html is a p
with
< P>< EM><强> ADFAà航空自卫队航空自卫队< / STRONG>< / EM>< / P>
所以,当转换完成后,Word文件的内容是一样的。
So when convert finished, the content of word file is the same
< P>< EM><强> ADFAà航空自卫队航空自卫队< / STRONG>< / EM>< / P>
我的code以下
[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;
}
我怎样才能解决这个问题?
How can I resolve it?
推荐答案
打开使用Word HTML文件,点击另存为,然后选择Word文档下的文件类型。
Open your HTML file with Word, click on "Save as" and choose "Word document" under "File type".
这篇关于将HTML转换成字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文