Export to excel - COMMA issue

Posted by 6242Y on Super User See other posts from Super User or by 6242Y
Published on 2014-06-11T08:50:14Z Indexed on 2014/06/11 9:28 UTC
Read the original article Hit count: 208

I want to put a string in an excel sheet from my Export to excel function.

However my string is as follows:

string : Red, red wine  Go to my head  Make me forget that I  Still need

and on my excel I get unexpected results , column change after comma and also column change when there is no full stop in front of an UPPER CASE alphabet.

The Upper case alphabets (without a full stop before them) are also causing this (Go , Make . Still)

How can I solve this issue ?

I tried removing the spaces after the comma as

var desc = "";
if (o.Description.Contains(','))
{
    var trimmedSplits = new List<string>();
    var splits = o.Description.Split(',');

    foreach (var stringBits in splits)
    {
        desc = desc + stringBits.Trim() + ",";
    }

    desc = desc.Remove(desc.Length - 1);
}

dtRow[(int)ProductRangeExportToExcel.Description] = desc;

© Super User or respective owner

Related posts about microsoft-excel

Related posts about export