Example #1
0
 /// <summary>
 /// 导入
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="stream">文件流</param>
 /// <param name="rowIndex">起始行</param>
 /// <returns></returns>
 public Task <ImportResult <T> > ImportAsync <T>(Stream stream, int rowIndex) where T : class, new()
 {
     using (var importer = new ImportRowRecords <T>(stream, rowIndex))
     {
         return(importer.Import());
     }
 }
Example #2
0
        /// <summary>
        /// 导入
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="stream">文件流</param>
        /// <param name="rowIndex">起始行</param>
        /// <param name="mapping">Excel映射列  </param>
        /// <returns></returns>
        public async Task <ImportResult <T> > ImportAsync <T>(Stream stream, int rowIndex, params string [] mapping) where T : class, new()
        {
            var importer = new ImportRowRecords <T>(stream, rowIndex, mapping);

            using (importer)
            {
                ImportResult <T> obj = null;
                try
                {
                    obj = await importer.Import();
                }
                finally
                {
                    if (importer.Data != null && obj != null)
                    {
                        obj.Data = importer.Data;
                    }
                }
                return(obj);
            }
        }