简体   繁体   English

使用Classic ASP将图像嵌入到单个Excel单元格中-这样可能吗?

[英]Embedding an image to a single Excel cell using Classic ASP - is such thing possible?

Short background - I'm exporting an Excel file using Classic ASP, in which I generate a table which is originated at an MS SQL database. 简短的背景 -我正在使用Classic ASP导出Excel文件,在其中生成一个表,该表起源于MS SQL数据库。

One of the columns I retrieve holds paths to images I have on my server. 我检索的列之一包含我在服务器上拥有的图像的路径。 I use the following code to define an "Excel-targeted" response: 我使用以下代码定义“以Excel为目标”的响应:

Response.ContentType="Application/vnd.ms-excel"
Response.AddHeader "content-disposition", "attachment; filename=""Sales_Report-"& Month(Date())&"-"& Day(Date())&"-"& Year(Date()) &"-"& ".xls"""

The problem - I've been googling for a solution and came to realize (correct me if I'm wrong here) that embedding it as "contents" of a single page is impossible. 问题 -我一直在寻找解决方案,并意识到(如果我在这里错了,请纠正我)将其嵌入为单个页面的“内容”是不可能的。

However, it is possible to either placing the image in one cell's remark (I'd like to avoid that), or alternatively just set the image as a cell's background. 但是,可以将图像放置在一个单元格的备注中(我想避免这种情况),也可以仅将图像设置为单元格的背景。

Important note - my goal is to have the images sort and filter with the rest of the row they're located in. I did manage to place the images exactly where they should be to begin with, but they just float as regular images in the spreadsheet. 重要说明 -我的目标是使图像与它们所在的其余行进行排序和过滤。我确实设法将图像准确地放置在它们应该开始的位置,但是它们只是像常规图像一样漂浮在电子表格。 I'm using plain HTML elements and not XML - but an XML solution (if exists) would also be awesome. 我使用的是纯HTML元素,而不是XML-但是XML解决方案(如果存在)也很棒。

Thanks. 谢谢。

OK, so after some research I've come to discover the research I was lacking to begin with. 好的,所以经过一些研究之后,我开始发现我缺乏的研究。 It obviously depends on the MS Excel version which eventually opens the generated file. 显然,这取决于最终打开生成文件的MS Excel版本

Generating XLS files with advanced cell settings is quite doable and intuitive when one acquires better understanding of the XML structures which help generating files through the code, with either Classic ASP & ASP.NET code behind. 当人们对XML结构有更好的了解时,生成具有高级单元格设置的XLS文件是相当可行和直观的,这有助于通过代码生成XML文件,而背后只有Classic ASP和ASP.NET代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM