public bool ImportEx(string filePath, params string[] arr) { DataTable dt = NPOIExcel.ExcelToTable(filePath); if (dt == null) { throw new Exception("数据导入异常"); } if (SaveData(dt, arr)) { //删除excel //File.Delete(filePath); return(true); } else { return(false); } }
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)); }