Running a VSTO add-in on Excel 2016 and VSTO 10.0.60825 (other versions are under test), I programmatically load a csv file from Temp folder through QueryTable object.
Just on a few PC and with some csv files, frequently but not always, data are partially loaded. I mean the worksheet is not properly populated with all csv file data.
The csv file does not contain any suspicious char nor data, the same csv sometimes is properly loaded, some other is not. It can happen when the csv contains thousands of rows or just a couple. Data can be completely absent or just a part is missing (at beginning, in the middle or at the end).
Already tried isolating the problem from any other logic and closing all applications but Excel, without succeed
The code is like the following and it had been working for ages:
QueryTable qt = ws.QueryTables.Add("TEXT;" + csvFileName, ws.Range["a1"], Type.Missing);
qt.Name = query.Code;
qt.FieldNames = false;
qt.RowNumbers = false;
qt.FillAdjacentFormulas = true;
qt.PreserveFormatting = true;
qt.AdjustColumnWidth = false;
qt.TextFilePlatform = 65001;
qt.TextFileStartRow = 1;
qt.TextFileParseType = XlTextParsingType.xlDelimited;
qt.TextFileTextQualifier = XlTextQualifier.xlTextQualifierDoubleQuote;
qt.TextFileConsecutiveDelimiter = false;
qt.TextFileTabDelimiter = false;
qt.TextFileSemicolonDelimiter = false;
qt.TextFileCommaDelimiter = true;
qt.TextFileSpaceDelimiter = false;
qt.TextFileColumnDataTypes = xlTypes;
qt.TextFileTrailingMinusNumbers = true;
qt.TextFileDecimalSeparator = ".";
qt.TextFileThousandsSeparator = ",";
qt.Refresh(false);
Range resRange = qt.ResultRange;
qt.Delete();
Any help would be much appreciated.
Cesare