This "howto" from microsoft:
TEXT
I solved my problem yesterday with:
Haro
TEXT
I solved my problem yesterday with:
var _with1 = oSheet.QueryTables.Add(connection: "TEXT;" + modGlobalVar.glStrCVSFullPath, destination: oRng);
_with1.Name = strSheetName;
_with1.FieldNames = true;
_with1.RowNumbers = false;
_with1.FillAdjacentFormulas = false;
_with1.PreserveFormatting = true;
_with1.RefreshOnFileOpen = false;
_with1.RefreshStyle = NetOffice.ExcelApi.Enums.XlCellInsertionMode.xlInsertDeleteCells;
_with1.SavePassword = false;
_with1.SaveData = true;
_with1.AdjustColumnWidth = true;
_with1.RefreshPeriod = 0;
_with1.TextFilePromptOnRefresh = false;
_with1.TextFilePlatform = (ExcelEnums.XlPlatform)1252;
_with1.TextFileStartRow = 1;
_with1.TextFileParseType = NetOffice.ExcelApi.Enums.XlTextParsingType.xlDelimited;
_with1.TextFileTextQualifier = NetOffice.ExcelApi.Enums.XlTextQualifier.xlTextQualifierNone;
_with1.TextFileConsecutiveDelimiter = false;
_with1.TextFileTabDelimiter = false;
_with1.TextFileSemicolonDelimiter = true;
_with1.TextFileCommaDelimiter = false;
_with1.TextFileSpaceDelimiter = false;
_with1.TextFileColumnDataTypes = arFieldinfo;
_with1.TextFileTrailingMinusNumbers = true;
_with1.Refresh(backgroundQuery: false);
arFieldinfo is an array like this:int[,] arFieldinfo = { { 1, 2 }, { 2, 2 }, { 3, 2 }, { 4, 1 } };
Quote from the site above:Optional XlColumnDataType. An array containing parse information for individual columns of data. The interpretation depends on the value of DataType. When the data is delimited, this argument is an array of two-element arrays, with each two-element array specifying the conversion options for a particular column. The first element is the column number (1-based), and the second element is one of theXlColumnDataType constants specifying how the column is parsed.
xlGeneralFormat General (1)
xlTextFormat Text (2)
xlMDYFormat MDY date (3)
xlDMYFormat DMY date (4)
xlYMDFormat YMD date (5)
xlMYDFormat MYD date (6)
xlDYMFormat DYM date (7)
xlYDMFormat YDM date (8)
xlEMDFormat EMD date (10)
xlSkipColumn Skip Column (9)
The data in parentheses correspond to the numerical value of the data type (public enum XlColumnDataType).Haro