在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
public static bool OpenCSVFile(ref DataTable mycsvdt, string filepath) { string strpath = filepath; int intColCount = 0; bool blnFlag = true; DataColumn mydc; DataRow mydr; string strline; string[] aryline; System.IO.StreamReader mysr = new System.IO.StreamReader(strpath, System.Text.Encoding.Default); while ((strline = mysr.ReadLine()) != null) { aryline = strline.Split(new char[] { ',' }); if (blnFlag) { blnFlag = false; intColCount = aryline.Length; int col = 0; for (int i = 0; i < aryline.Length; i++) { col = i + 1; mydc = new DataColumn(aryline[i]); mycsvdt.Columns.Add(mydc); } } mydr = mycsvdt.NewRow(); for (int i = 0; i < intColCount; i++) { mydr[i] = aryline[i]; } mycsvdt.Rows.Add(mydr); } return true; } }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论