public virtual ExtractStatus Import(ExcelFileReader recordSource) { recordSource.Next(); try { ExtractStatus r = this.Extract(recordSource); if (r == ExtractStatus.ValueMismatched) { recordSource.Previous(); } return(r); } catch (Exception exc) { throw new Exception(string.Format("Line {0} : ", recordSource.LineNo), exc); } }
/// <summary> /// Import records to create an instance of T that would be put in the property Value. /// </summary> /// <param name="reader"></param> /// <returns></returns> public override ExtractStatus Import(ExcelFileReader reader) { this.HeaderMapper.Value = null; ExtractStatus r = this.HeaderMapper.Import(reader); if (r != ExtractStatus.Success) { return(r); } this.Target = this.DetailMapper.Target = this.FooterMapper.Value = this.HeaderMapper.Value; r = this.DetailMapper.Import(reader); if (r == ExtractStatus.Success) { reader.Next(); r = this.FooterMapper.Extract(reader); } 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); }