/// <summary> /// Decremental operator to substract 1 from the selected XLNumber value /// </summary> /// <param name="target">the target XLNumber</param> /// <returns>the resulting XLNumber</returns> public static XLNumber operator --(XLNumber target) { XLNumber retVal = new XLNumber(target.number); retVal.number--; return(retVal); }
/// <summary> /// Reads consumption-compilant portions of Data from the underlaying data-source /// </summary> /// <returns>an IEnumerable of the base-set</returns> protected override IEnumerable <IBasicKeyValueProvider> ReadData() { IWorkbook book = OpenWorkbook(sourceFile); bool foundSheet = false; for (int i = 0; i < book.NumberOfSheets; i++) { string msg; ISheet sheet = book.GetSheetAt(i); if ((ImportWorkSheetDecider.Decide(sheet.SheetName, DecisionMethod.Simple, out msg) & (DecisionResult.Acceptable | DecisionResult.Success)) != DecisionResult.None) { foundSheet = true; yield return (new DictionaryWrapper(new Dictionary <string, object> { { "SheetName", sheet.SheetName } })); foreach (IRow row in sheet) { if (row != null) { Dictionary <string, object> vals = new Dictionary <string, object>(); foreach (ICell cell in row.Cells) { XLNumber num = cell.ColumnIndex; object value = GetCellValue(cell, cell.CellType); if (value != null) { vals.Add(num.ToString(), value); } } string origin = $"{sheet.SheetName}::{row.RowNum}"; vals.Add("$origin", origin); yield return(new DictionaryWrapper(vals)); } } } } if (!foundSheet) { LogParserEvent(null, $@"No sheet has met the configured Constraints. Settings for sheet-search: {ImportWorkSheetDecider}", ParserEventSeverity.Warning, null); } }
/// <summary> /// Reads consumption-compilant portions of Data from the underlaying data-source /// </summary> /// <returns>an IEnumerable of the base-set</returns> protected override IEnumerable <IDictionary <string, ExcelDataRecord> > ReadData() { IWorkbook book = OpenWorkbook(sourceFile); bool foundSheet = false; for (int i = 0; i < book.NumberOfSheets; i++) { string msg; ISheet sheet = book.GetSheetAt(i); if ((ImportWorkSheetDecider.Decide(sheet.SheetName, DecisionMethod.Simple, out msg) & (DecisionResult.Acceptable | DecisionResult.Success)) != DecisionResult.None) { foundSheet = true; yield return (new Dictionary <string, ExcelDataRecord> { { "SheetName", new ExcelDataRecord { FormattedText = sheet.SheetName, RawData = sheet.SheetName } } }); DataFormatter f = new DataFormatter(); foreach (IRow row in sheet) { if (row != null) { Dictionary <string, ExcelDataRecord> vals = new Dictionary <string, ExcelDataRecord>(); foreach (ICell cell in row.Cells) { XLNumber num = cell.ColumnIndex; object value = GetCellValue(cell, cell.CellType); if (value != null) { vals.Add(num.ToString(), new ExcelDataRecord { RawData = value, FormattedText = f.FormatCellValue(cell) }); } else if (readNullData) { vals.Add(num.ToString(), new ExcelDataRecord { RawData = null, FormattedText = "" }); } } string origin = $"{sheet.SheetName}::{row.RowNum}"; vals.Add("$origin", new ExcelDataRecord { FormattedText = origin, RawData = origin }); yield return(vals); } } } } if (!foundSheet) { LogParserEvent(null, $@"No sheet has met the configured Constraints. Settings for sheet-search: {ImportWorkSheetDecider}", ParserEventSeverity.Warning, null); } }
/// <summary> /// Subtraction operator to subtract a specific value /// </summary> /// <param name="target">the target XLNumber</param> /// <param name="subtraction">the value to substract from it</param> /// <returns>the resulting XLNumber</returns> public static XLNumber operator -(XLNumber target, int subtraction) { XLNumber retVal = new XLNumber(target.number - subtraction); return(retVal); }
/// <summary> /// Addition operator used to add to a specific value /// </summary> /// <param name="target">the target number</param> /// <param name="addition">the value to add to it</param> /// <returns>the resulting XLNumber</returns> public static XLNumber operator +(XLNumber target, int addition) { XLNumber retVal = new XLNumber(target.number + addition); return(retVal); }