Exemplo n.º 1
0
        public Dictionary <int, string> ParseOneRow(int rowIndex)
        {
            // description
            var dataDict = new Dictionary <int, string>();

            for (var colIndex = 0; colIndex < _configData.Columns.Count; ++colIndex)
            {
                var cell = ExcelUtility.GetCell(_configData, rowIndex, colIndex).Trim();
                if (string.IsNullOrEmpty(cell))
                {
                    Debug.LogError("Warning! empty cell! at row:" + rowIndex + " col:" + colIndex);
                }
                else
                {
                    dataDict[colIndex] = cell;
                }
            }

            return(dataDict);
        }
Exemplo n.º 2
0
        public Dictionary <int, string> ParseOneColumn(int colIndex)
        {
            // description
            string cell;
            var    dataDict = new Dictionary <int, string>();

            for (var rowIndex = Config.DATA_ROW_START_INDEX; rowIndex < _configData.Rows.Count; ++rowIndex)
            {
                cell = ExcelUtility.GetCell(_configData, rowIndex, colIndex).Trim();
                if (string.IsNullOrEmpty(cell))
                {
                    Debug.LogError("Warning! empty cell! at row:" + rowIndex + " col:" + colIndex);
                }
                else
                {
                    dataDict[rowIndex] = cell;
                }
            }

            return(dataDict);
        }
Exemplo n.º 3
0
        public object GetCellData(string dataType, int rowIndex, int colIndex)
        {
            // 获取数据类型信息
            //   int DATA_TYPE_ROW_INDEX = 3;
            // string dataType = ExcelUtility.GetCell(configData, DATA_TYPE_ROW_INDEX, colIndex);
            //Debug.Log("数据类型是:" + dataType);
            dataType = dataType.ToUpper();
            // 返回对象
            object ret = null;

            // 若是默认值
            var content = ExcelUtility.GetCell(_configData, rowIndex, colIndex);

            //if (string.IsNullOrEmpty(content.Trim()))
            //{
            //    switch (dataType)
            //    {
            //        case "INT":
            //            try
            //            {
            //                ret = int.Parse(dictDefaultVal2ColIndex[colIndex]);
            //            }
            //            catch
            //            {
            //                Debug.LogError("DataError: rowIndex: " + rowIndex + "colIndex:" + colIndex + content);
            //            }
            //            break;
            //        case "FLOAT":
            //            ret = float.Parse(dictDefaultVal2ColIndex[colIndex]);
            //            break;
            //        case "BOOL":
            //            ret = bool.Parse(dictDefaultVal2ColIndex[colIndex]);
            //            break;
            //        case "STRING":
            //            ret = dictDefaultVal2ColIndex[colIndex];
            //            break;
            //        case "STRINGKEY":
            //            string stringKey = dictDefaultVal2ColIndex[colIndex];
            //            ret = GetMultiLanguageText(stringKey);
            //            break;

            //        case "LIST":
            //            ret = ParseListData(dictDefaultVal2ColIndex[colIndex]);
            //            break;
            //        case "TEXT":
            //            //object languageID = dictDefaultVal2ColIndex[colIndex];
            //            //ret = GetMultiLanguageText(languageID);
            //            break;
            //        default:
            //            Debug.LogError("错误:未知的数据类型 " + dataType);
            //            break;
            //    }

            //    return ret;
            //}

            // 若是非默认值
            switch (dataType)
            {
            case "INT":
                ret = ExcelUtility.GetIntCell(_configData, rowIndex, colIndex);
                break;

            case "FLOAT":
                ret = ExcelUtility.GetFloatCell(_configData, rowIndex, colIndex);
                break;

            case "BOOL":
                ret = ExcelUtility.GetBoolCell(_configData, rowIndex, colIndex);
                break;

            case "STRING":
                ret = ExcelUtility.GetCell(_configData, rowIndex, colIndex);
                break;

            //case "STRINGKEY":
            //    string stringKey = ExcelUtility.GetCell(configData, rowIndex, colIndex);
            //    ret = GetMultiLanguageText(stringKey);
            //    break;
            case "LIST":
                var data = ExcelUtility.GetCell(_configData, rowIndex, colIndex);
                ret = ParseListData(data);
                break;

            case "LIST<STRING>":
                ret = ExcelUtility.GetCell(_configData, rowIndex, colIndex);
                ret = ParseStringListData((string)ret);
                break;

            case "LIST<INT>":
                ret = ExcelUtility.GetCell(_configData, rowIndex, colIndex);
                ret = ParseListData((string)ret);
                break;

            case "TEXT":
                //object languageID = ExcelUtility.GetCell(configData, rowIndex, colIndex);
                //ret = GetMultiLanguageText(languageID);
                break;

            default:
                Debug.LogError("错误:未知的数据类型 " + dataType);
                break;
            }

            return(ret);
        }