Beispiel #1
0
 //文件合并
 private void FileMerge(object obj)
 {
     try
     {
         var dic = (Dictionary<string, object>)obj;
         var isToFile = Convert.ToBoolean(dic["isToFile"]);
         var files = dic["file"] as List<string>;
         if (files == null) return;
         var tables = new List<DataTable>();
         for (int i = 0, len = files.Count; i < len; i++)
         {
             var helper = new ExcelHelper(files[i]);
             var table = helper.ExcelToDataTable("Sheet1", true);
             if (table == null || table.Rows.Count == 0) continue;
             tables.Add(table);
         }
         if (tables.Count == 0) return;
         var k = isToFile ? MergeToSingleSheet(tables) : MergeToMultSheet(tables);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     SetLableText("文件已经保存到D盘");
 }
Beispiel #2
0
 //文件拆分
 //isToFile 是否拆分成文件
 private void FileSplit(object obj)
 {
     var dic = (Dictionary<string, object>)obj;
     var isToFile = Convert.ToBoolean(dic["isToFile"]);
     var file = dic["file"].ToString();
     var count = Convert.ToInt32(dic["fileCount"]);
     var helper = new ExcelHelper(file);
     var table = helper.ExcelToDataTable("Sheet1", true);
     if (table == null || table.Rows.Count == 0) return;
     var i = isToFile ? SplitToMultFile(table, count)
         : SplitMultSheet(table, count);
     SetLableText("文件已经保存到D盘");
 }