我正在尝试使用ASP Classic在服务器上自动制作一些word文件。它工作得很好,但唯一的问题是,当我下载文件时,里面没有图片,相反,我得到了类似占位符的东西。下面是我的代码:
set fso = createobject("scripting.filesystemobject")
Set act = fso.CreateTextFile(server.mappath("/") & file_being_created, true)
act.WriteLine("<html xmlns:v=""urn:schemas-microsoft-com:vml""")
act.WriteLine("xmlns:o=""urn:schemas-microsoft-com:office:office""")
act.WriteLine("xmlns:w=""urn:schemas-microsoft-com:office:word""")
act.WriteLine("xmlns:m=""http://schemas.microsoft.com/office/2004/12/omml""")
act.WriteLine("xmlns:css=""http://macVmlSchemaUri"" xmlns=""http://www.w3.org/TR/REC-html40"">")
act.WriteLine("<title>testing</title>")
act.WriteLine("<body> " )
act.WriteLine("<img src='http://mysite.com/images/pic.jpg' width='800' height='200'/><br />" )
act.WriteLine(rsInvoices("invoiceClientID") & "<br />" )
act.WriteLine(rsInvoices("invoiceNumber") )
act.WriteLine("</body></html>")"
act.close
有没有想法在word文件中有图片?提前谢谢。
发布于 2011-01-29 15:06:51
好的,为了得到这个答案,我创建了一个新的Word文档(使用Word 2010),从我的硬盘中插入一张图片,然后将文件保存为HTML文件。然后我看了看结果页面,试图解构Word在做什么。我发现除了超文本标记语言<img>标记之外,Word还创建了一个被conditional comment隐藏的<v:shape>元素。这是我根据你的例子想出来的:
<!--[if gte vml 1]>
<v:shape id="Picture1" style="width:800px;height:200px;">
<v:imagedata src="http://mysite.com/images/pic.jpg"/>
</v:shape>
<![endif]-->
<![if !vml]>
<img src='http://mysite.com/images/pic.jpg' width='800' height='200' v:shapes="Picture1"/>
<![endif]>如果您将此文件作为.doc文件提供服务,则可以通过只包含<v:shape>元素并省略条件注释来节省一些空间和重复内容。
<v:shape id="Picture1" style="width:800px;height:200px;">
<v:imagedata src="http://mysite.com/images/pic.jpg"/>
</v:shape>https://stackoverflow.com/questions/4825370
复制相似问题