简体   繁体   English

是否可以在Excel中的文本开头隐藏单引号(')?

[英]Is it possible to hide single quote (') in the beginning of a text in excel?

I have an application that when I click Run Report the data will be generated and exported to excel. 我有一个应用程序,当我单击“运行报告”时,将生成数据并将其导出到excel。 I posted a question regarding about a value converted to date when exporting in excel. 我发布了一个有关在Excel中导出时转换为日期的值的问题。 My first problem was that I have a data in a column Requisition No. which is the value is for example like this 08-20 but when I export it on excel it will became a date like 20-Aug So I put a single quote in my code for it to identify as text and not convert to date. 我的第一个问题是,我在“请08-20号”列中有一个数据,例如,其值类似于08-20但是当我将其导出到excel时,它的日期将变为20-Aug所以我在其中输入了单引号我的代码可以将其识别为文本,而不是转换为日期。

If arrColumn(intColCount2) = 29 Then
    strHTML += "<td>&#145;" & dr("vRequisition") & "</td>"
End If

but now it shows like this in excel 但现在它在excel中显示为

电子表格

I get the output that I want for my first problem which is not to convert the value into a date. 我得到我想要的第一个问题的输出,该输出不是将值转换为日期。

what I'm trying to do is to hide the single quote (') at the beginning of the text in excel so that it will show only like this 我想做的是在excel的文本开头隐藏单引号('),以便它仅显示为

08-20

is it possible to hide the single quote (') in the beginning of the text in excel? 是否可以在excel的文本开头隐藏单引号(')?

Your code seems not to create really Excel format workbooks but simply to create HTML and to export this HTML to Excel. 您的代码似乎并不是真正创建Excel格式的工作簿,而仅仅是创建HTML并将此HTML导出到Excel。

Using this approach you can use CSS Styling Excel cells with mso-number-format to number format the td as text format for Excel. 使用这种方法,您可以使用CSS 样式为mso-number-format的Excel单元格将td数字格式化为Excel的文本格式。

Example

strHTML += "<td style='mso-number-format:""\@""'>" & dr("vRequisition") & "</td>"

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

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