首页 > 代码库 > CSV表格读取

CSV表格读取

  读取CSV表格需要CSV表格的编码格式为UTF-8 ,这个脚本中有些是为了方便使用封装的dll 不过都是一些简单的实现,自己实现也很容易,可做参考。

 1   /// <summary>
 2     /// 构件施工动画转list
 3     /// </summary>
 4     /// <returns></returns>
 5     public static List<NodeAnima> GetGouJianShiGongList()
 6     {
 7         //路径
 8         string filePath = string.Format("{0}/_Lesson/构件施工动画.csv", PublicJs.Datapath);
 9 
10         string strline = string.Empty;
11         string[] aryline;
12         int line = 0;
13         //需要的类型对象的list
14         List<NodeAnima> fbxList = new List<NodeAnima>();
15         //开始解析
16         FileStream fs;
17         StreamReader sr;
18         FileHelp.Instance.GetFileStream(filePath, out fs, out sr);
19         while ((strline = sr.ReadLine()) != null)
20         {
21             //首行,添加为table列
22             if (line > 0)
23             {
24                 aryline = strline.Split(new char[] { , });
25                 NodeAnima model = new NodeAnima();
26                 model.ID = aryline[0];
27                 model.JoinID = aryline[1];
28                 model.JoinName = aryline[2];
29                 model.LeiXing = aryline[3];
30                 fbxList.Add(model);
31             }
32             line++;
33         }
34         sr.Dispose(); sr.Close();
35         fs.Dispose(); fs.Close();
36         return fbxList;
37     }

 

CSV表格读取