예제 #1
0
        private void AddComment(Workbook wb, Worksheet st, ExcelTitle title, int column)
        {
            var cell = st.Cells[ExcelConst.TITLE_ROW, column];

            if (cell == null)
            {
                return;
            }

            CellArea area = new CellArea();

            area.StartRow    = ExcelConst.TITLE_ROW;
            area.EndRow      = ExcelConst.TITLE_ROW;
            area.StartColumn = column;
            area.EndColumn   = column;
            int        validationIndex = st.Validations.Add(area);
            Validation validation      = st.Validations[validationIndex];

            validation.Type         = (ValidationType.TextLength);
            validation.InputMessage = title.titleComment;
            validation.InputTitle   = title.title;
        }
예제 #2
0
        public void Init()
        {
            var titles = new List <ExcelTitle>();

            if (type == TAB_TYPE.ENUM)
            {
                var menus = new List <string>();
                foreach (EnumItemConfig it in items)
                {
                    menus.Add(it.alias);
                }
                var title = new ExcelTitle(alias, TableGlobalConfig.Instance.enumTypeDesc, alias + "_enum_comment")
                {
                    menus = menus
                };
                titles.Add(title);
            }
            else
            {
                foreach (BeanItemConfig it in items)
                {
                    int    listSize = 1;
                    string pre      = "";
                    if (it.isList)
                    {
                        listSize = it.listSize;
                        pre      = it.alias;
                    }
                    for (int itemIndex = 1; itemIndex <= listSize; ++itemIndex)
                    {
                        var curTitle     = it.isList ? pre + itemIndex : pre + it.alias;
                        var baseTypeDesc = TableGlobalConfig.Instance.GetBaseTypeDesc(it.type);
                        if (baseTypeDesc != null)
                        {
                            //基础类型
                            var title = new ExcelTitle(curTitle, it.type);
                            title.titleComment += baseTypeDesc + TableLuaDefine.LINE_SEP;
                            titles.Add(title);
                            continue;
                        }
                        var tableUnit = TableLuaDefine.Instance.GetItemTableUnit(it.type);
                        if (tableUnit == null)
                        {
                            throw new Exception(string.Format("undefined bean type:{0},tableName={1}", it.type, name));
                        }

                        //子类
                        foreach (var itTitle in tableUnit.unitTitles)
                        {
                            var title = new ExcelTitle(curTitle + itTitle.title, itTitle.typeAlias, itTitle.titleComment)
                            {
                                menus = itTitle.menus
                            };
                            if (tableUnit.type == TAB_TYPE.ENUM)
                            {
                                title.title = curTitle;
                                title.menus = itTitle.menus;
                            }
                            titles.Add(title);
                        }
                    }
                }
            }
            unitTitles = titles;
        }