I was looking at the solution suggested here:
C# Excel Interop: Opening and Showing CSV file
excel.Workbooks.OpenText(filename,
DataType: Excel.XlTextParsingType.xlDelimited,
TextQualifier: Excel.XlTextQualifier.xlTextQualifierNone,
ConsecutiveDelimiter: true,
Semicolon: true);
This code opens the CSV file but does not split the data on the semicolon.
If I open the file manually in Excel and use the same options as specified here it works just fine, so I must be missing something.
Any suggestions?
Update: Part of the CSV
> Betalings Enveloppe;;;;Dossier;ACME ;;;;Dagboek;;F4 - AAA
> 46846846-;;; ;;;;Rekening;54654684684684;;;;BIC;;null;;; ;;;;Betaal
> datum;Fri Mar 16 00:00:00 CET 2012;;;;EnveloppeId;;0002;;;
> Document;;Datum;Rekeningnummer;;;;BIC;Referentie;;Leverancier;;;Bedrag;
> 2012/A1/268;;29/02/2012;BE94684684684128;;;;BBRUBEBB;BLUB ;;DOKTER WHO
> ;;;28.0 ?;
I think the extension is your problem. I tried the following code with both CSV and TXT extensions, it worked as a TXT, but not as a CSV.
All I did was create a string array for each row and add it to a list, then I just wrote each array (joined on the pipe ‘|’, and it looks like it split everything correctly when TXT was the extension. I would guess that the special nature CSV files have in excel might be causing the problem