导出到 Excel 无法正确显示数字
将数据从数据库导出到 Excel 电子表格时,我很难正确显示帐号。一家公司的帐号显示正确。然而,其他人则不然。用户必须双击单元格才能查看整个帐号。我用谷歌搜索了这个问题,但我尝试过的解决方案都不起作用。
<cfsetting enablecfoutputonly="Yes">
<cfsavecontent variable="sTest">
<cfoutput>
<table>
<tr><th align="center">ATTUID</th>
<th>Company Name</th>
<th align="center">Account Number </th>
<th align="center">Total Past Due Balance</th>
<th align="center">Date Sent</th>
</tr>
<cfloop query="returnQuery">
<tr><td>#attuid#</td>
<td>#companyname#</td>
<td>#AccountNum4#</td>
<td>#totalpastdue#</td>
<td>#dateformat(posted)# #timeformat(posted, "h:mm tt")#</td>
</tr>
</cfloop>
</table>
</cfoutput>
</cfsavecontent>
<cfcontent type="application/vnd.msexcel">
<cfheader name="Content-Disposition" value="inline; filename=export.xls">
<cfoutput>#sTest#</cfoutput>
I'm having a hard time getting account numbers to display correctly when exporting data from database to an Excel spreadsheet. The account number for one company, shows up correctly. However, others don't. Users have to double click in the cell to see the whole account number. I have Googled this issue and none of the solutions that I've tried worked.
<cfsetting enablecfoutputonly="Yes">
<cfsavecontent variable="sTest">
<cfoutput>
<table>
<tr><th align="center">ATTUID</th>
<th>Company Name</th>
<th align="center">Account Number </th>
<th align="center">Total Past Due Balance</th>
<th align="center">Date Sent</th>
</tr>
<cfloop query="returnQuery">
<tr><td>#attuid#</td>
<td>#companyname#</td>
<td>#AccountNum4#</td>
<td>#totalpastdue#</td>
<td>#dateformat(posted)# #timeformat(posted, "h:mm tt")#</td>
</tr>
</cfloop>
</table>
</cfoutput>
</cfsavecontent>
<cfcontent type="application/vnd.msexcel">
<cfheader name="Content-Disposition" value="inline; filename=export.xls">
<cfoutput>#sTest#</cfoutput>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果要导出 html,您还可以使用 xml mso 架构属性将数字格式化为文本,而无需更改实际单元格值,即添加撇号。
If you are exporting html, you could also use the xml mso schema properties to format the number as text, without changing the actual cell value ie adding an apostrophe.
您可以在帐号前插入撇号 '。这将强制 Excel 将数字(任何)数据视为文本。
You can insert an apostrophe ' preceding the account number. This will force excel to treat numeric (any) data as text.
当列的宽度不足以显示数据时,通常会发生这种情况。尝试将列加宽,看看是否可以解决问题。
This usually happens when the column is not wide enough to display the data. Try and make the column wider and see if that corrects the issue.