简体   繁体   English

使用经典ASP引入包括表情符号在内的电子表格内容

[英]Using Classic ASP to bring in spreadsheet content including emojis

I need to write a small script to take the contents of an XLS file and lay them out nicely in a web page. 我需要编写一个小脚本来获取XLS文件的内容,并将它们很好地放在网页中。 So far, so easy. 到目前为止,这么容易。 However, the spreadsheet text will be the content of a series of social media posts which includes emojis within that content. 但是,电子表格文本将是一系列社交媒体帖子的内容,其中包括该内容中的表情符号。 I did a very basic test and found that the emojis turn into question marks when dropped to the page by the script. 我做了一个非常基本的测试,发现当脚本放到页面时,表情符号会变成问号。

I don't particularly like emojis myself but I don't get to choose whether they are included in the text, and they need to appear in the end result. 我自己并不特别喜欢表情符号,但我不能选择它们是否包含在文本中,并且它们需要出现在最终结果中。

Here's what a stripped back version of the script looks like, with no formatting etc. 这是脚本的剥离版本的样子,没有格式化等。

<%@ Language=VBScript%>
<html><head></head>
<body>
<%
Dim objConn, objRS
Set objConn = Server.CreateObject("ADODB.Connection")
filepath = "xls/OPG.xls"
objConn.Open "DRIVER={Microsoft Excel Driver (*.xls)}; IMEX=1; HDR=NO; Excel 8.0; DBQ=" & Server.MapPath(filepath) & "; "
strSQL = "SELECT * FROM A1:C400"
Set objRS=objConn.Execute(strSQL)

Set DataList = CreateObject("ADOR.Recordset")

Do Until objRS.EOF

Response.Write objRS.Fields("Post Description").Value & "<br /><br />"
objRS.MoveNext
Loop
objConn.Close
Set objConn=Nothing
%>
</body>
</html>

Here's what the original XLS file looks like... 这是原始XLS文件的样子......

Excel文件原件

...and here's how that comes into the web page... ......以及这是如何进入网页的......

结果

How do I get around this? 我该如何解决这个问题? Any ideas? 有任何想法吗?

Thanks 谢谢

The Microsoft Access Database Engine is able to read and display emojis from Excel files: https://www.microsoft.com/en-us/download/details.aspx?id=54920 Microsoft Access数据库引擎能够从Excel文件中读取和显示表情符号: https//www.microsoft.com/en-us/download/details.aspx? id = 53920

You will need to set your codepage and charset to UTF-8 though: 您需要将代码页和字符集设置为UTF-8:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%

    response.Charset = "utf-8"

%>

Connection string: 连接字符串:

objConn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Server.MapPath(filepath) & ";Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX=1"";"

Tested and working. 经过测试和工作。

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

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