txt导入excel,双引号之后的数据丢失
比如txt中某行的数据是[aaa,bbb"ccc,ddd,eee],导入后,双引号之后的数据丢失,下行数据正常.代码如下:
Range("A8").Select
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
strODBC _
), Array( _
"ab,txt;FIL=text;ImplicitCommitSync=Yes;MaxBufferSize=512;MaxScanRows=25;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;Us" _
), Array("erCommitSync=Yes;")), Destination:=Range("A8"))
.Sql = Array( _
strSQL _
)
.FieldNames = True
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = True
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SavePassword = True
.SaveData = False
End With
[解决办法]
先将TXT中的双引号替换成比如等“=”,导入Excel后,再替换成原来的双引号。
[解决办法]
用open xxx for xxx as xx语句的方式导入
[解决办法]
"替换为""再看