html转word
我用的ASP.NET,要做一个导出word的功能。现在导出如下图

把这个拖一下就可以,但在程序里面该怎么设置让他靠左边点?我代码生成代码

把这个拖一下就可以,但在程序里面该怎么设置让他靠左边点?我代码生成代码
string _html = "";
if (Request.Form["hidhtml"] != null && Request.Form["hidhtml"].ToString().Trim() != string.Empty)
{
//取得网页的html代码
_html = Request.Form["hidhtml"].ToString();
_html = new Regex("title(.*?)\"(.*?)\"").Replace(_html, "");
string path = Server.MapPath("\\upload") + GetSaveFilePath(); //创建文件夹算法
//因為Web 是多執行緒環境,避免甲產生的文件被乙下載去,所以檔名都用唯一
string fileNameWithOutExtention = path.Substring(path.LastIndexOf("\\") + 1);
string strPath = path + ".doc";
//生成word
Document _doc = new Document();
DocumentBuilder _builder = new DocumentBuilder(_doc);
_builder.InsertHtml(_html);
_doc.Save(strPath, Aspose.Words.SaveFormat.Doc);
//檔案下載
//把檔案讀進串流
FileStream fs = new FileStream(strPath, FileMode.Open);
byte[] file = new byte[fs.Length];
fs.Read(file, 0, file.Length);
fs.Close();
//Response給用戶端下載
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/msword";
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + fileNameWithOutExtention + ".doc");//強制下載
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.BinaryWrite(file);
Response.End();
}
...全文
相关推荐
HTML转WORD WORD转PDF
HTML转WORD WORD转PDF 自己编写的 正在使用
Java html转word 使用FreeMarker
java 将html转为word,使用Freemarker 比较好装好。方便好用。也可以转换成pdf格式。
php word转html格式类
这个PHP函数可以将word文件内容转换成html格式,注意:不是直接将word文件转html文件,而是对其内容进行转换输出。
java html 转word word 转pdf
java html 转word word 转pdf
Java实现Word转PDF、HTML教程
在信息技术的高速发展下,不同格式的文档转换需求日益增长。对于Java开发者而言,Word到PDF和HTML的转换是常见的应用场景。这种转换不仅关乎文档格式的适配,也涉及到用户阅读体验的优化和多平台兼容性的提升。本章将概述Java环境下实现Word文档转换为PDF和HTML格式的基本概念、应用场景以及转换流程,为后续章节的技术细节和实践操作提供宏观指导和背景铺垫。


