question

CantieriCesare-0640 avatar image
0 Votes"
CantieriCesare-0640 asked emilyhua-msft edited

VSTO - QueryTable from csv frequently load incompletely

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











office-vsto-com-dev
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@CantieriCesare-0640
As tag “office-excel-itpro” focus on general issues of Excel client, but your issue is more realted to VSTO, I would remove this tag.
Thanks for your understanding.

1 Vote 1 ·

0 Answers