Hi,
Nothing is wrong with the file, it is just that it is not in UTF8 encoding, and FlexCel by default tries to open it as if it was UTF8-encoded.
This is actually one of the biggest problems with using CSV: You need to know which encoding was used to create the file. In this case I am not really sure on what encoding the file has, but it is not UTF8, since it has sequences of characters which are invalid in UTF8. When you try to open a file with encoding UTF8 and it has characters that are invalid in a UTF8 string, Delphi will just reject the full thing and return an empty string. And this is why rowcount is 0: FlexCel is looking at an empty string.
Normally, if the file was created in a "western" locale, the encoding is Win1252:https://en.wikipedia.org/wiki/Windows-1252
But it might be 1251 for example if it is a russian locale.
If you try with win1252 encoding, the number of rows is correct:
program Project59;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
VCL.FlexCel.Core,
FlexCel.XlsAdapter;
var
xls: TXlsFile;
i: integer;
colTypes: Tarray<TColumnImportType>;
Encoding: TEncoding;
begin
xls := TXlsFile.Create(true);
try
SetLength(colTypes, 2000);
for i := 0 to 1999 do colTypes := TColumnImportType.Text;
Encoding := TEncoding.GetEncoding(1252);
try
xls.Open('r:\Elp_95.csv', TFileFormats.Text, #9, 1, 1, colTypes, nil, Encoding, true);
finally
Encoding.Free;
end;
WriteLn(xls.RowCount);
ReadLn;
finally
xls.Free;
end;
end.
But I am not really sure the text will be the correct one. You will only get the correct text if you specify the correct encoding which was used to create the file.