访问换行符变成_x000D_

Access newline becoming _x000D_

我正在尝试根据我在 excel 中的数据生成访问报告。所以我使用外部数据选项在访问中导入我的 excel sheet,但我的换行符一直显示为“_x000D_”

作为示例,我使用了一个 excel sheet,其中包含 4 列,所有列均带有标题,并且所有列均包含 1 行数据,从左到右依次包含:

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

在我的 excel sheet 中,我尝试将换行符更改为我能想到的所有内容,但似乎已经完成某些操作的两个是 char(10) 和 char(13) 但是 char (10) 根本没有出现在访问中,char(13) 似乎变成了“_x000D_”

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));

所以在 Excel 单元格中放置换行符的唯一正确方法是您的第一个版本:

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

然后在导入 table 之后,使用更新查询将 Lf 替换为 Access 换行符 CrLf