在ASP中将图像插入word文件
我正在尝试使用 ASP Classic 在服务器上自动创建一些 Word 文件。它工作正常,但唯一的问题是当我下载文件时,其中没有图片,而是得到类似占位符的东西。这是我的代码:
set fso = createobject("scripting.filesystemobject")
设置 act = fso.CreateTextFile(server.mappath("/") & file_being_created, true)
act.WriteLine("
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/oml""")
act.WriteLine("xmlns:css=""http://macVmlSchemaUri"" xmlns=""http://www.w3.org/TR/REC-html40"">")
act.WriteLine("
act.WriteLine(" ")
act.WriteLine("
>" )< /代码>act.WriteLine(rsInvoices("invoiceClientID") & "
" )act.WriteLine(rsInvoices("invoiceNumber") )
act.WriteLine("")"
act.close
你知道在Word文件中添加图片吗? 提前致谢。
Im trying to automatically make some word file on server using ASP Classic. It works fine but the only problem is when I download the files there is no picture in them instead I get something like place holder. Here is my code:
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
Any idea to have picture in word file?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,为了得到这个答案,我所做的就是创建一个新的 Word 文档(使用 Word 2010),插入硬盘中的图片,然后将该文件另存为 HTML 文件。然后我查看了生成的页面并尝试解构 Word 正在做什么。我发现除了 HTML
标记之外,Word 还创建了一个
元素,该元素被 条件注释。以下是我根据您的示例得出的结论:如果您将此文件作为 .doc 文件提供,则可以通过仅包含
元素和省略有条件的评论。Okay, what I did to get to this answer was to create a new Word document (using Word 2010), insert a picture from my hard drive, then save the file as an HTML file. Then I looked at the resulting page and tried to deconstruct what Word was doing. What I found was that in addition to the HTML
<img>
tag, Word also created a<v:shape>
element, hidden by a conditional comment. Here is what I came up based on your example:If you're serving this file as a .doc file, you could save some space and duplication by only including the
<v:shape>
element and leaving out the conditional comments.