asp.net - create csv file from multiple datatables in c# -
i want export data multiple datatables csv file.
i know how write 1 datatable csv.
any please. have function
public void createcsvfile(datatable dt, string strfilepath) { try { streamwriter sw = new streamwriter(strfilepath, false); int columncount = dt.columns.count; (int = 0; < columncount ; i++) { sw.write(dt.columns[i]); if (i < columncount - 1) { sw.write(","); } } sw.write(sw.newline); foreach (datarow dr in dt.rows) { (int = 0; < columncount ; i++) { if (!convert.isdbnull(dr[i])) { sw.write(dr[i].tostring()); } if (i < columncount - 1) { sw.write(","); } } sw.write(sw.newline); } sw.close(); } catch (exception ex) { throw ex; } }
Comments
Post a Comment