コード例 #1
0
ファイル: FileManager.cs プロジェクト: dragnilar/reanimator
        public int _GetExcelRowIndex(ExcelFile excelTable, String value)
        {
            FieldInfo field         = excelTable.Attributes.RowType.GetFields()[0];
            bool      isStringField = (field.FieldType == typeof(String));

            ObjectDelegator excelDelegator = DataFileDelegators[excelTable.StringId];

            ObjectDelegator.FieldGetValueDelegate getValue = excelDelegator[field.Name];

            int i = 0;

            foreach (Object row in excelTable.Rows)
            {
                if (isStringField)
                {
                    String val = (String)getValue(row);
                    if (val == value)
                    {
                        return(i);
                    }
                }
                else // string offset
                {
                    int    offset    = (int)getValue(row);
                    String stringVal = excelTable.ReadStringTable(offset);
                    if (stringVal == value)
                    {
                        return(i);
                    }
                }
                i++;
            }

            return(-1);
        }
コード例 #2
0
ファイル: FileManager.cs プロジェクト: dragnilar/reanimator
        public int GetExcelRowIndexFromStringId(String stringId, int value, String colName)
        {
            if (DataFiles == null || String.IsNullOrEmpty(stringId) || DataFiles.ContainsKey(stringId) == false)
            {
                return(-1);
            }

            ExcelFile       excelFile      = (ExcelFile)DataFiles[stringId];
            ObjectDelegator excelDelegator = DataFileDelegators[stringId];

            ObjectDelegator.FieldGetValueDelegate getValue = excelDelegator[colName];

            int  rowIndex = -1;
            bool foundRow = false;

            foreach (Object row in excelFile.Rows)
            {
                rowIndex++;

                int    intVal;
                Object val = getValue(row);
                if (val is short)
                {
                    intVal = (int)(short)val;
                }
                else
                {
                    intVal = (int)val;
                }

                if (intVal != value)
                {
                    continue;
                }

                foundRow = true;
                break;
            }

            return((foundRow) ? rowIndex : -1);
        }