停止 Ms Excel 自动将数字字符串格式化为数字
我正在将报告从 MS Access(2003) 导出到 Excel (97-2003) 输出。
其中一列的某些行具有数字字符串,例如“05-0880”。
当我在 MS Excel 中打开输出文件时,相应的单元格设置为数字 -372424。
我认为这是由于 Excel 很“聪明”,决定“05-0808”代表某种时间值或日期,并将字符串转换为相应的数值。
就我而言,数据代表产品代码,这种转换是非常不可取的。 如果我导出报表基础查询的输出(导出数据表),则不会发生此转换。 (建议 Access 必须能够以防止转换的方式输出为 Excel 格式)。
我尝试更改报告中字段的格式属性,但没有“文本”选项,并且“标准”的行为似乎与将其留空相同。
有没有办法使用 format() 函数强制字符串输出? 如果是这样,当 Excel 仍然可以进行巧妙的转换时,这还会有帮助吗?
仅使用底层查询作为输出是一种选择,但并不理想,因为格式和分组会丢失。 将报告导出为文本格式是一场灾难,因为列没有分隔。
I am exporting a report from MS Access(2003) to Excel (97-2003) output.
One of the columns has a character string that is numeric for some rows e.g. "05-0880".
When I open the output file in MS Excel the corresponding cell is set to the number -372424.
I assume this is caused by Excel being "clever" and deciding that "05-0808" represents a time value or date of some sort and converting the string to a corresponding numeric value.
In my case the data represents product codes and this conversion is very undesirable.
If I export the output of the report's underlying query (exporting a Datasheet) this conversion does not happen. (Suggesting that it must be possible for Access to output to Excel format in a way that prevents conversion).
I tried changing the format attribute of the field in the report, but there is no "Text" option, and "Standard" seems to behave the same as leaving it blank.
Is there a way to use the format() function to force string output?
If so, will this even help when Excel may still do its clever conversion?
Just using the underlying query as output is an option but not ideal because formatting and grouping are lost. Exporting a report to a text format is a disaster because the columns are not delimited.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
事实上,情况更像是相反。 MS Access 太笨了,无法从报告中正确导出它。 您可以用引号或撇号来保护数据; 然而,如您所知,这非常难看并且需要后期处理。
我的解决方法是仔细设计一个查询,然后导出查询结果而不是报告。 这将为您带来预期的结果。
Actually, it is more like the other way around. MS Access is too dumb to export it properly from a report. You can armor the data with quotes or apostrophes; however, as you know, that's quite ugly and requires post processing.
My way around it was to carefully craft a query and then export the results of the query rather than the report. This will give you the results you expect.
导出“'05-0880”而不是“05-0880”。
Export "'05-0880" instead of "05-0880".
确保使用单引号而不是其他撇号。
make sure you use the single quote not the other apostrophe.