Excel FieldInfo parameter: what works?

Here is Xojo code that I was able to get to work, and I had to change the csv file to a txt file.

You can download the example project and txt file here: Xojo and Txt file

Sub Pressed() Handles Pressed
  Var Excel as new ExcelApplication
  Excel.Visible = true
  Excel.Workbooks.add
  var mytable as excelquerytables
  mytable = Excel.Activesheet.QueryTables.Add("TEXT;C:\Users\eugen\Desktop\New\ExcelFIeldInfoParameter\ExcelParameter\BookTab4.txt", excel.Range("$A$1"))
  mytable.Name = excel.ActiveWorkbook.Name //changed
  mytable.FieldNames = True
  mytable.RowNumbers = False
  mytable.FillAdjacentFormulas = False
  mytable.PreserveFormatting = True
  mytable.RefreshOnFileOpen = False
  mytable.RefreshStyle = office.xlInsertDeleteCells
  mytable.SavePassword = False
  mytable.SaveData = True
  mytable.AdjustColumnWidth = True
  mytable.RefreshPeriod = 0
  mytable.TextFilePromptOnRefresh = False
  mytable.TextFilePlatform = 437
  mytable.TextFileStartRow = 1
  mytable.TextFileParseType = office.xlDelimited
  mytable.TextFileTextQualifier = office.xlTextQualifierDoubleQuote
  mytable.TextFileConsecutiveDelimiter = False
  mytable.TextFileTabDelimiter = True
  mytable.TextFileSemicolonDelimiter = False
  mytable.TextFileCommaDelimiter = True
  mytable.TextFileSpaceDelimiter = False
  
  Var AnArray() as Variant
  AnArray.add 1
  AnArray.add 2
  AnArray.add 2
  mytable.TextFileColumnDataTypes = AnArray  ' 3 columns: general, text, text
  mytable.TextFileTrailingMinusNumbers = True
  mytable.Refresh 'BackgroundQuery.False ' Refresh must be last
End Sub

Thanks, Eugene. Excellent!

Yes, it worked with your changes.

TextFilePlatform =: xlWindows or 437 or 65001 all produced the same correct Excel values with a UTF-8 file for me.

1 Like