1 /// <summary> 2 /// 新建一个DataTable(只针对一列) 3 /// </summary> 4 /// <param name="dataStr"></param> 5 /// <param name="titleName"></param> 6 /// <returns></returns> 7 private DataTable NewDataTable(string[] dataStr, string titleName) 8 { 9 try 10 { 11 DataTable ptDt = new DataTable(); 12 ptDt.Columns.Add(titleName); 13 for (int i = 0; i < dataStr.Length; i++) 14 { 15 DataRow ptFixed = ptDt.NewRow(); 16 object[] objFixed = { dataStr[i] }; 17 ptFixed.ItemArray = objFixed; 18 ptDt.Rows.Add(ptFixed); 19 } 20 return ptDt; 21 } 22 catch { return null; } 23 }
时间: 2024-10-26 23:29:50