コード例 #1
0
ファイル: ExcelImportBase.cs プロジェクト: wsnowxue/wxx
        public List <ErrorItem> Scan(string filePath, string[] keyValue)
        {
            List <ErrorItem> list = new List <ErrorItem>();
            //检查表头
            List <String> headerList = NPOIExcel.ExcelHeaderToList(filePath);

            //if (headerList == null) throw new Exception("数据模板错误");
            if (!CheckHeader(headerList, list, keyValue))
            {
                File.Delete(filePath);
                return(list);
            }
            //检查数据
            DataTable dt = NPOIExcel.ExcelToTable(filePath);

            if (dt == null || dt.Rows.Count == 0)
            {
                //删除excel
                File.Delete(filePath);
                throw new Exception("Excel数据为空!");
            }

            return(CheckData(dt, list, keyValue));
        }