在VBA中导入UTF-8文件 [英] Import UTF-8 file in VBA
问题描述
我想在表中导入管道分隔文件,但是该文件为具有动态结构的UTF-8.
I'd like to import a pipe delimited file in a table but this file is in UTF-8 with dynamic structure.
我曾经尝试过使用TranfertText和FSO,但是只有ADODB.Stream似乎可以很好地处理这种编码,但是它只能读取全文...
I had tried with TranfertText and FSO but only ADODB.Stream seems to deal well with such an encoding however it only read the full text...
如何读取每行这样的文件行以在现有表中添加行?
How can I read such a file line per line to add rows in an existing table ?
谢谢.
推荐答案
您可以从ADO Stream中读取一行,其 ReadText 方法.
You can read a line from an ADO Stream with its ReadText method.
strLine = objStream.ReadText -2 ' adReadLine
您可能需要先设置流的 LineSeparator 属性.
You may need to set your stream's LineSeparator property first.
阅读该行后,您可以分割竖线字符.
After you read the line, you can split on the pipe character.
Split(strLine, "|")
这篇关于在VBA中导入UTF-8文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!