[C#] DataTable 遍历数据 →→→→→进入此内容的聊天室

来自 , 2019-06-13, 写在 C#, 查看 130 次.
URL http://www.code666.cn/view/d3fad7d3
  1.  class Program
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.             try
  6.             {
  7.                 var sheet = ExcelHleper.ReadData(@"C:\Users\rht\Desktop\MouseWithoutBorders\读取的文件1.xls", 0);            
  8.                 ShowTableInf(sheet, new methodProcessData(Func));
  9.            
  10.             }
  11.             catch (Exception e)
  12.             {
  13.                 Console.WriteLine(e.Message);
  14.                
  15.             }
  16.             Console.ReadKey();
  17.         }
  18.  
  19.         private delegate void methodProcessData(Object dtat);
  20.         static void Func(Object data)
  21.         {
  22.             Console.Write(data.ToString()+"\t");
  23.         }
  24.         static void ShowTableInf(DataTable table,methodProcessData func)
  25.         {
  26.             Console.WriteLine("Rown Count is:"+table.Rows.Count);
  27.             Console.WriteLine("Column Count is:" +table.Columns.Count);
  28.            
  29.             Console.ReadKey();
  30.             foreach (DataRow curRow in table.Rows)
  31.             {
  32.                 Console.WriteLine(" ");
  33.                
  34.                 foreach (var item in curRow.ItemArray)
  35.                 {
  36.                     func(item);
  37.                 }
  38.                
  39.             }
  40.         }
  41.  

回复 "DataTable 遍历数据"

这儿你可以回复上面这条便签

captcha