Access newline becoming _x000D_

好久不见. 提交于 2019-12-10 13:09:14

问题


I'm trying to make a report in access derived from data I have in excel. So I import my excel sheet in access using the external data options, but my newlines keep appearing as "_x000D_"

As a example I use a excel sheet with 4 columns all with a title and all with 1 row of data containing in order from left to right:

="a"&char(10)&"b" 
="a"&char(13)&"b" 
="a"&char(10)&char(13)&"b" 
="a"&char(13)&char(10)&"b"

In my excel sheet I have tried changing the newlines to everything I could think of but the two that appeared to have done something are char(10) and char(13) however char(10) doesn't appear in access at all and char(13) appears to become "_x000D_"


回答1:


See How to import from Excel and keep the line breaks :

Excel uses line-feed character (ASCII 10) as the line separator, while Access uses the combination of carriage-return + line-feed (ASCII 13 followed by ASCII 10) as the line separator.

After importing, you can use the Replace function to replace Chr(10) with Chr(13)+Chr(10). For example, you could execute a query like this:

UPDATE ImportedExcelTable SET MyField = Replace([MyField], Chr(10), Chr(13) & Chr(10));

So the only correct way to put a newline in an Excel cell is your first version:

="a"&char(10)&"b"

Then after importing the table, use the Update query to replace the Lf with Access newlines CrLf.



来源:https://stackoverflow.com/questions/36167807/access-newline-becoming-x000d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!