Exemple #1
0
        public bool TryConverValue(TableRect rect, ITable value, out TTargetType convertedValue)
        {
            TableRect relrect   = value.Rect.GetRelativeCoordinateRect(rect).GetRelativeCoordinateRect(Rect);
            string    key       = value.GetCellData(relrect);
            TableRect tableRect = parseAddress.ParseRect(key);
            string    tablename = parseAddress.GetTableName(key);
            string    sheetname = parseAddress.GetSheetName(key);

            tablename = String.IsNullOrEmpty(tablename) ? value.TableName : tablename;
            sheetname = String.IsNullOrEmpty(sheetname) ? value.SheetName : sheetname;
            ITable table = tableContext.GetTable(tablename, sheetname);

            if (tableRect.Area == 0)
            {
                tableRect = table.Rect;
            }
            if (!ConverterMapping.TryConvert(tableRect, table, out convertedValue))
            {
                return(false);
            }

            return(true);
        }
        public bool TryMapValue(TEntity entity, ITable value, TableRect rect)
        {
            TableRect relrect   = value.Rect.GetRelativeCoordinateRect(rect).GetRelativeCoordinateRect(Rect);
            string    key       = value.GetCellData(relrect);
            TableRect tableRect = parseAddress.ParseRect(key);
            string    tablename = parseAddress.GetTableName(key);
            string    sheetname = parseAddress.GetSheetName(key);

            tablename = String.IsNullOrEmpty(tablename) ? value.TableName : tablename;
            sheetname = String.IsNullOrEmpty(sheetname) ? value.SheetName : sheetname;
            ITable table = tableContext.GetTable(tablename, sheetname);

            if (tableRect.Area == 0)
            {
                tableRect = table.Rect;
            }
            if (!propertyConverter.TryConvert(tableRect, table, out TProperty convertedValue))
            {
                return(false);
            }
            propertySetter(entity, convertedValue);

            return(true);
        }
Exemple #3
0
        public void GetSheetNameTest1()
        {
            string res = parse.GetSheetName(testdata);

            Assert.AreEqual(res, "Sheet");
        }