我正在尝试根据 Excel 中的数据生成 Access 权限报告。因此,我使用外部数据选项在 Access 中导入 Excel 工作表,但我的换行符始终显示为“_x000D_”
作为示例,我使用一个包含 4 列的 Excel 工作表,所有列均带有标题,并且全部包含 1 行数据,按从左到右的顺序包含:
="a"&char(10)&"b"
="a"&char(13)&"b"
="a"&char(10)&char(13)&"b"
="a"&char(13)&char(10)&"b"
在我的 Excel 工作表中,我尝试将换行符更改为我能想到的所有内容,但似乎做了一些事情的两个是 char(10) 和 char(13),但是 char(10) 没有出现在 Access 中all 和 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"
导入表后,使用更新查询将 Lf
替换为 Access 换行符 CrLf
。
关于excel - Access 换行符成为_x000D_,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36167807/