解决方案
20
是导出的时候吗?是这种效果吗?
020001,020001,礼券,0,0 020002,020002,测试1,22,1 020003,020003,黄瓜,14,1 020004,020004,后肘,23,1 020005,020005,前肘,24,1 020006,020006,韭菜,18,1 020007,020007,礼品储值卡,0,0 020008,020008,青椒,8,1 020009,020009,猪肝,43,1
可以参考一下代码
var data = dataGridView1.Rows.Cast<DataGridViewRow>().Select(r => string.Join(",", r.Cells.Cast<DataGridViewCell>().Select(c => { if (c.ColumnIndex == 4) { if (c.Value == "KG") return 1; else return 0; } return c.Value; }))); File.WriteAllLines("1.csv", data,Encoding.UTF8);