Ejemplo n.º 1
0
 public CSObject(Excel.ExcelData excelData)
 {
     try
     {
         name = excelData.name;
         InternalConstruction(excelData);
     }
     catch (Exception e)
     {
         Common.Utility.Logger.Log("parse excel:{0} to cs objects.", name);
         throw e;
     }
 }
Ejemplo n.º 2
0
        private void InternalConstruction(Excel.ExcelData excelData)
        {
            System.Data.DataTable data = excelData.data;
            CheckSourceData(data);

            DataRowCollection rows = data.Rows;

            int dataStartIndex = Define.UserDefine.global.excel.startIndex;

            if (rows.Count <= dataStartIndex)
            {
                throw new Exception(string.Format("Excel Data rows count:{0} can not less than excel start index:{1}", rows.Count, Define.UserDefine.global.excel.startIndex));
            }

            int columnCount = data.Columns.Count;

            type = new CSObjectTypeGroup(rows[Define.UserDefine.global.excel.typeIndex], columnCount, name);

            List <int> ignoreIndexs = type.ignoreIndexs;

            int           propertyIndex    = Define.UserDefine.global.excel.propertyIndex;
            List <string> propertyOriginal = FiterRowData(rows[propertyIndex], columnCount, ignoreIndexs, string.Format("propertyIndex:{0}", propertyIndex));

            int           summaryIndex    = Define.UserDefine.global.excel.summaryIndex;
            List <string> summaryOriginal = FiterRowData(rows[summaryIndex], columnCount, ignoreIndexs, string.Format("summaryIndex:{0}", summaryIndex));

            property = new CSObjectPropertyGroup(summaryOriginal, propertyOriginal);

            objectDatas = new List <CSObjectData>();
            for (int i = dataStartIndex; i < rows.Count; i++)
            {
                List <string> originalData = FiterRowData(rows[i], columnCount, ignoreIndexs, string.Format("Data Row:{0}", i));
                CSObjectData  objectData   = new CSObjectData(originalData, i);
                CheckObjectKey(objectData, i);
                objectDatas.Add(objectData);
            }
        }