+ Reply to Thread
Results 1 to 2 of 2

Importing CSV files in Excel

  1. #1
    Lamer
    Guest

    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. #2
    Tom Ogilvy
    Guest

    Re: 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 news:10va98roa6vv3d6@corp.supernews.com...
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1