c# - No quotef for first value in csv -
i trying make simple csv file, works except 1 tiny thing : when file opened in excel, first value of each entry isn't quoted, e.g :
username,"fullname","fullname@company.com"
and here code :
stringbuilder sb = new stringbuilder(); // user info foreach (user u in listusers) { sb.appendformat("\"{0}\",\"{1}\",\"{2}\"\r\n", u.username, u.fullname, u.email); } // generate csv response.clear(); response.contenttype = "text/csv"; response.addheader("content-disposition", "attachment; filename=\"" + "usersexport.csv" + "\""); response.write(sb.tostring()); response.end();
any idea?
Comments
Post a Comment