#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Mar 2014
    Posts
    1
    Rep Power
    0

    Question Excel Delimiter Splitting


    Hi Friends,

    I have an excel file and I am splitting cell content based on special charectors as shown below:

    dt =new DataTable();

    dt.Columns.Add("Name");

    dt.Columns.Add("Age");

    dt.Columns.Add("Skills");

    dt.Columns.Add("counts");

    string name = rdr[0].ToString();

    string age = rdr[1].ToString();

    char[] s = new char[1] { ';' };

    char[] k=new char[1] {'@'};

    string[] skills = rdr[2].ToString().Split(s);

    string[] counts = rdr[3].ToString().Split(k);

    (ie) If i have below table







    Name

    Age

    Skills

    counts



    kk

    31

    .net;sqlserver;oracle


    1@2@3@



    output will be :

    kk 31 .net 1

    sql 2

    oracle 3


    I am successfull in achieveing above output.

    Required Output1:

    if you have 1@# 2@# 3@# in counts column instead of 1@2@3@,the how do i split below expression?

    char[] k=new char[1] {'@'};

    Required Output2:

    how to split expression (char[] k=new char[1] {'@'};---> if i have both @# and @ (ie) like: 1@# 2@ 3@ in 'counts' column.

    here also i want output as :

    1

    2

    3



    Hope I am clear.Please help me in sorting this issue.



    Thanks,

    Kranthi
  2. #2
  3. I do .NET for a living
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Sep 2003
    Location
    Florida
    Posts
    1,558
    Rep Power
    214
    Originally Posted by Kdampuru
    Hi Friends,

    I have an excel file and I am splitting cell content based on special charectors as shown below:

    dt =new DataTable();

    dt.Columns.Add("Name");

    dt.Columns.Add("Age");

    dt.Columns.Add("Skills");

    dt.Columns.Add("counts");

    string name = rdr[0].ToString();

    string age = rdr[1].ToString();

    char[] s = new char[1] { ';' };

    char[] k=new char[1] {'@'};

    string[] skills = rdr[2].ToString().Split(s);

    string[] counts = rdr[3].ToString().Split(k);

    (ie) If i have below table







    Name

    Age

    Skills

    counts



    kk

    31

    .net;sqlserver;oracle


    1@2@3@



    output will be :

    kk 31 .net 1

    sql 2

    oracle 3


    I am successfull in achieveing above output.

    Required Output1:

    if you have 1@# 2@# 3@# in counts column instead of 1@2@3@,the how do i split below expression?

    char[] k=new char[1] {'@'};

    Required Output2:

    how to split expression (char[] k=new char[1] {'@'};---> if i have both @# and @ (ie) like: 1@# 2@ 3@ in 'counts' column.

    here also i want output as :

    1

    2

    3



    Hope I am clear.Please help me in sorting this issue.



    Thanks,

    Kranthi
    Change string[] counts = rdr[3].ToString().Split(k);

    to

    string[] counts = rdr[3].ToString().Replace("#","").Split(k);

    Comments on this post

    • Will-O-The-Wisp agrees
    Roger (.NET MCP)

Similar Threads

  1. Name Splitting in Excel with VBA
    By 213emi in forum Visual Basic Programming
    Replies: 2
    Last Post: April 10th, 2010, 06:23 AM
  2. Replies: 7
    Last Post: January 28th, 2008, 12:51 PM
  3. String to access with delimiter pipes
    By sumesh12 in forum Microsoft Access Help
    Replies: 2
    Last Post: November 28th, 2007, 09:20 AM
  4. Createing Excel File Splitting pages
    By teeheiman in forum ASP Development
    Replies: 7
    Last Post: July 10th, 2006, 07:33 PM
  5. Change default delimiter
    By watersk in forum HTML, JavaScript And CSS Help
    Replies: 5
    Last Post: August 26th, 2004, 10:10 AM

IMN logo majestic logo threadwatch logo seochat tools logo