Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Importing CSV files in Excel

When I try to import a .CSV file programatically in Excel, the result is not
satisfying. Afterwards, I have to set the document to 'delimited' by hand,
using the "convert text to columns wizard".

When I open the CSV file with Explorer, I get the desired format imediately,
namely each semicolon separated piece of text in a separate column.

My CSV is as follows:
"Aap"; "Noot"; "Mies"; "Wim"
"Snappy"; "das"; "kleine"; "krokodil"
"Ik"; "snap";"niks";"van";"excel"

It is imported like this (C#):

Excel.ApplicationClass excel = new Excel.ApplicationClass();
excel.Visible = false;
excel.Workbooks.OpenText(tmp_file_name, Missing.Value, Missing.Value,
XlTextParsingType.xlDelimited, XlTextQualifier.xlTextQualifierDoubleQuote,
Missing.Value, Missing.Value, true, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value);
Can someone explain to me what I am doing wrong? Thanks!

Atrhur


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Importing CSV files in Excel

Rename the file with a .txt extension before you open it. When it has a
..csv extension, your settings are ignored.

--
Regards,
Tom Ogilvy


"Lamer" <@ wrote in message ...
When I try to import a .CSV file programatically in Excel, the result is

not
satisfying. Afterwards, I have to set the document to 'delimited' by hand,
using the "convert text to columns wizard".

When I open the CSV file with Explorer, I get the desired format

imediately,
namely each semicolon separated piece of text in a separate column.

My CSV is as follows:
"Aap"; "Noot"; "Mies"; "Wim"
"Snappy"; "das"; "kleine"; "krokodil"
"Ik"; "snap";"niks";"van";"excel"

It is imported like this (C#):

Excel.ApplicationClass excel = new Excel.ApplicationClass();
excel.Visible = false;
excel.Workbooks.OpenText(tmp_file_name, Missing.Value, Missing.Value,
XlTextParsingType.xlDelimited, XlTextQualifier.xlTextQualifierDoubleQuote,
Missing.Value, Missing.Value, true, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value);
Can someone explain to me what I am doing wrong? Thanks!

Atrhur




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing CVS files into Excel summerelli Excel Discussion (Misc queries) 2 August 31st 09 03:14 AM
Importing a Value from many Excel Files STOVK Excel Discussion (Misc queries) 2 September 25th 06 02:23 AM
Importing Files into Excel [email protected] Excel Discussion (Misc queries) 2 June 27th 06 06:43 PM
Importing CSV files into Excel Doug Excel Discussion (Misc queries) 9 August 24th 05 08:22 PM
Excel VBA-Importing txt files with VBA pwdiaz Excel Programming 1 June 17th 04 03:44 PM


All times are GMT +1. The time now is 08:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"