public override ExtractStatus Import(String filePath, out T t) { ExcelFileReader reader = null; t = null; ExtractStatus r = ExtractStatus.Success; try { reader = new ExcelFileReader(filePath); if (null != this.OnImportStartHandler) { this.OnImportStartHandler(filePath, t); } r = this.RecordMapping.Import(reader); if (r == ExtractStatus.Success) { t = this.RecordMapping.Target; reader.Close(); if (null != this.OnImportFinishHandler) { this.OnImportFinishHandler(filePath, t); } } } catch (Exception exc) { reader.Close(); if (!(exc is EndOfStreamException)) { throw exc; } } return(r); }
public override IList <T> Import(String filePath) { IList <T> records = new List <T>(); if (null == this.RecordMapping) { throw new iSabayaException(Messages.DetailRecordFormatNotDefined); } ExcelFileReader excelFileReader = new ExcelFileReader(filePath); //read and process the first line excelFileReader.CurrentRowNo = this.LineNoOfFirstDetailRecord; this.RecordBuffer = (Worksheet)excelFileReader.Next(); Range endRow = this.RecordBuffer.get_Range("A1", Missing.Value).get_End(XlDirection.xlDown); int endRowNo = endRow.Row; //for (excelFileReader.CurrentRowNo = this.LineNoOfFirstDetailRecord; excelFileReader.CurrentRowNo <= endRowNo; ++excelFileReader.CurrentRowNo) // records.Add(this.RecordMapping.Import(excelFileReader)); excelFileReader.Close(); return(records); }