乔山办公网我们一直在努力
您的位置:乔山办公网 > word文档 > ASP.NET 页面内容导出word,图片不显示的问题-.net 显示word,pi network

ASP.NET 页面内容导出word,图片不显示的问题-.net 显示word,pi network

作者:乔山办公网日期:

返回目录:word文档


你使用npoi导出试试 它可以直接把word互相转换

首先要使用图片的绝对路径,如果还是没有看到图片,说明word没有internet链接,其实用html内容直接转word有这种问题是一定的。
如果是企业级的系统,是有必要购买一些好的html转word的第三方工具。不能只是html直接生成word文档,归根结底生成后的word文档其实还是html格式,只不过换了个后缀名而已。
要达到这种效果,e799bee5baa6e997aee7ad94e59b9ee7ad94339把生成的简历的内容都放在一个table里,然后用JS导出。
给你个例子参考。表格中可以包括图片等元素,都可以正常导出。
<table width="100%" border="1" id = "PrintA">
<tr>
<td>dfsdfds</td>
<td>&dsfds</td>
<td>&sdf;</td>
<td><img src="1.jpg"/></td>
</tr>
<tr>
<td>dsf</td>
<td>dsfds</td>
<td>fsdfdsfdsf</td>
<td>dsfs</td>
</tr>
<tr>
<td>dsfds</td>
<td>dsf</td>
<td>dsfd</td>
<td>sfds</td>
</tr>
<tr>
<td> </td>
<td>sdf</td>
<td>fdsf</td>
<td> </td>
</tr>
</table>
<input type="button" onclick="javascript:AllAreaWord();" value="导出页面指定区域内容到Word">
<script type="text/javascript" language="javascript">
//指定页面区域内容导入Word
function AllAreaWord()
{
var oWD = new ActiveXObject("Word.Application");
var oDC = oWD.Documents.Add("",0,1);
var oRange =oDC.Range(0,1);
var sel = document.body.createTextRange();
sel.moveToElementText(PrintA);
sel.select();
sel.execCommand("Copy");
oRange.Paste();
oWD.Application.Visible = true;
//window.close();
oWD.ActiveWindow.ActivePane.View.Type=3
oWD.Application.close;
}
</SCRIPT>
</body></html>

用普通7a686964616fe4b893e5b19e338的保存成word的代码是不能实现的,我曾经是用c#引用Microsoft.Office.Interop.Word来创建word,才能在其中添加图片,不知道对你有没有用:

Object Nothing = System.Reflection.Missing.Value;
Directory.CreateDirectory("C:/CNSI"); //创建文件所在目录
string name = "CNSI_" + DateTime.Now.ToShortDateString()+ ".doc";
object filename = "C://CNSI//" + name; //文件保存路径
//创建Word文档
Application WordApp = new ApplicationClass();
Document WordDoc = WordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);

//插入图片
string FileName = Server.MapPath("~/http_imgloadCADN55WM.jpg");//图片所在路径
object LinkToFile = false;
object SaveWithDocument = true;
object Anchor = WordDoc.Application.Selection.Range;
WordDoc.Application.ActiveDocument.InlineShapes.AddPicture(FileName, ref LinkToFile, ref SaveWithDocument, ref Anchor);
// WordDoc.Application.ActiveDocument.InlineShapes[1].Width = 100f;//图片宽度
// WordDoc.Application.ActiveDocument.InlineShapes[1].Height = 100f;//图片高度
//文件保存
WordDoc.SaveAs(ref filename, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
WordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
WordApp.Quit(ref Nothing, ref Nothing, ref Nothing);

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网