So let’s say I have a string entering into an Excel document set up like this
output.WriteLine(string.Format("{0},{1},{2},{3}",
var1,
var2,
var3,
var4
));
Now normally it would enter each var into a separate cell.
However, I find that if one of my vars has a comma in it, it will treat that as a cell ending, and go to the next one. How can I ignore commas in the vars while maintaining the set up?
I’m assuming this is a CSV file that you’re creating. As such you would need to wrap the value that has the comma in it with double quotes. You can either wrap everything (which is easier, like:
Or you could write a small helper function like:
And then do: