예제 #1
0
        private void writeExcelHeader()
        {
            sheet.WriteStartRow(1);
            sheet.WriteTextCell(1, _writer.AddSharedString("类别"));
            int columnIndex = 2;

            for (; columnIndex - 2 < _excelColumnHeader.Count; columnIndex++)
            {
                sheet.WriteTextCell(columnIndex, _writer.AddSharedString(string.Format("元素{0}", _excelColumnHeader[columnIndex - 2] as string)));
            }
        }
예제 #2
0
        public bool FillPage()
        {
            this.GetSelectedText();
            if (string.IsNullOrEmpty(this.SelectedText))
            {
                return(true);
            }
            string    path        = GetSelectedNodePath();
            TreeValue currentPage = TreeValue;

            if (path != null)
            {
                currentPage = currentPage.Select(path);
            }
            if (currentPage == null)
            {
                return(false);
            }

            if (currentPage != null && currentPage.Parent != null)
            {
#if export
                if (writer == null)
                {
                    writer = new Office.Excel.ForwardExcelWriter(string.Format("{0}\\{1}.xlsx", Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "3C下拉列表框"));
                    writer.Open();
                    sheet = writer.CreateWorksheet() as Office.Excel.ForwardWriteWorksheet;
                    sheet.WriteNextRow();
                    sheet.WriteTextCell(1, writer.AddSharedString("CCC编号"));
                }
#endif
                _pageData = currentPage.Values;
                FillPage(currentPage);
            }

            foreach (TreeValue child in currentPage.Children)
            {
                if (child.IsAppendNode)
                {
                    IntPtr childPtr = FindChild(_selectedNode, child.Name);
                    if (childPtr != IntPtr.Zero)
                    {
                        _treeView.ScrollIntoView(childPtr);
                        this.AppendNode(childPtr, child.Suffix);
                    }
                    Match match = child.Name == null ? Match.Empty : nodeMatcher.Match(child.Name);
                    if (match.Success)
                    {
                        if (match.Groups["no"].Value == "C10.1.1.1")
                        {
                            child.Rename("C10.1.1.1前照灯(远光/近光)");
                        }
                    }
                }
            }
            return(true);
        }
예제 #3
0
        /// <summary>
        /// 生成树结构
        /// </summary>
        public void GenerateDir()
        {
            if (main == null)
            {
                main = Main_3C.GetMainWindow("", processId);
            }
            if (main.TreeView.GetCount() == 0)
            {
                return;
            }
            TreeValue root = main.GetTreeStructure();

            using (Office.Excel.ForwardExcelWriter writer = new Office.Excel.ForwardExcelWriter("目录字典.xlsx"))
            {
                writer.Open();
                Office.Excel.ForwardWriteWorksheet sheet = writer.CreateWorksheet() as Office.Excel.ForwardWriteWorksheet;
                sheet.WriteNextRow();
                sheet.WriteTextCell(1, writer.AddSharedString("Id"));
                sheet.WriteTextCell(2, writer.AddSharedString("目录名称"));
                sheet.WriteTextCell(3, writer.AddSharedString("父级目录Id"));
                WriteTreeDir(sheet, root);
            }
        }
예제 #4
0
        /// <summary>
        /// 根据参数键值及控件句柄填写参数。
        /// </summary>
        /// <param name="key"></param>
        /// <param name="fillControl"></param>
        /// <returns></returns>
        private bool FillValue(string key, object fillControl)
        {
            IntPtr        current = IntPtr.Zero;
            List <IntPtr> list    = fillControl as List <IntPtr>;

            if (list != null && list.Count == 0)
            {
                return(true);
            }

            if (string.IsNullOrEmpty(key))
            {
                return(true);
            }
            FillParameter3C fillParameter = _fillParameters[key] as FillParameter3C;

            if (fillParameter == null)
            {
                fillParameter = new FillParameter3C()
                {
                    Key = key, Separators = FillParameter3C.DefaultSeparators
                };
                _fillParameters.Add(key, fillParameter);
            }
            FillValue3C fillValue = _pageData[key] as FillValue3C;

            if (fillValue == null)
            {
                Records.Add(new FillRecord(ElementType.Unknown, RecordType.Failed, "数据文件中未定义此参数", key));
                return(true);
            }
            StringBuilder className = new StringBuilder(256);
            string        name      = "";

            if (list != null)
            {
                current   = list[0];
                className = new StringBuilder(256);
                NativeApi.GetClassName(current, className, 255);
                name = className.ToString();
                // 勾选是否适用复选框
                if (name.StartsWith(CCCFillManager.ButtonClassName))
                {
                    if (fillValue.Value == "N/A")
                    {
                        if (ApiSetter.IsDisabled(current) == false)
                        {
                            ApiSetter.SetCheck(current, this.Hwnd);
                            //ApiSetter.ClickButton(current, this.Hwnd, null, null);
                            return(true);
                        }
                    }
                    current = list.Count > 1 ? list[list.Count - 1] : current;
                }
            }
            else
            {
                current = (IntPtr)fillControl;
            }


            if (fillParameter.Type == "5" || fillParameter.Type == "7")
            {
                return(FillCheckBox(fillParameter, current));
            }


            className.Clear();
            NativeApi.GetClassName(current, className, 255);
            name = className.ToString();
            if (name.StartsWith(CCCFillManager.StaticClassName))
            {
                return(true);
            }
            else if (name.StartsWith(CCCFillManager.EditClassName))
            {
                return(FillValue(CCCFillManager.EditClassName, current, fillValue));
            }
            else if (name.StartsWith(CCCFillManager.ButtonClassName))
            {
                return(FillValue(CCCFillManager.ButtonClassName, current, fillValue));
            }
            else if (name.StartsWith(CCCFillManager.ComboBoxClassName))
            {
#if export
                sheet.WriteNextRow();
                sheet.WriteTextCell(1, writer.AddSharedString(key));
#endif
                return(FillValue(CCCFillManager.ComboBoxClassName, current, fillValue));
            }
            else
            {   // 多值填报
                List <IntPtr> sortedControl = ControlSorter.SortContainer(current);
                if (sortedControl == null)
                {
                    return(false);
                }
                else if (sortedControl.Count == 1)
                {
                    return(FillValue(key, sortedControl[0]));
                }
                int valueIndex = 0;
                for (int i = 0; i < sortedControl.Count; i++, valueIndex++)
                {
                    className.Clear();
                    NativeApi.GetClassName(sortedControl[i], className, 255);
                    if (className.ToString().StartsWith(CCCFillManager.ButtonClassName))
                    {
                        FillValue(CCCFillManager.ButtonClassName, ref valueIndex, sortedControl[i], fillValue);
                    }
                    else if (className.ToString().StartsWith(CCCFillManager.ComboBoxClassName))
                    {
#if export
                        sheet.WriteNextRow();
                        sheet.WriteTextCell(1, writer.AddSharedString(key));
#endif
                        FillValue(CCCFillManager.ComboBoxClassName, ref valueIndex, sortedControl[i], fillValue);
                    }
                    else if (className.ToString().StartsWith(CCCFillManager.EditClassName))
                    {
                        FillValue(CCCFillManager.EditClassName, ref valueIndex, sortedControl[i], fillValue);
                    }
                }
            }
            return(true);
        }
예제 #5
0
        private void writeExcelHeader()
        {
            _sheet.WriteStartRow(1);
            _sheet.WriteTextCell(1, _writer.AddSharedString(_typeColumnHeader));
            _sheet.WriteTextCell(2, _writer.AddSharedString(_paraNameColumnHeader));
            _sheet.WriteTextCell(3, _writer.AddSharedString(_elementTypeColumnHeader));
            _sheet.WriteTextCell(4, _writer.AddSharedString("frameId"));
            _sheet.WriteTextCell(5, _writer.AddSharedString("Url"));
            int columnIndex = 6;

            for (; columnIndex - 6 < _excelColumnHeader.Count; columnIndex++)
            {
                _sheet.WriteTextCell(columnIndex, _writer.AddSharedString(_excelColumnHeader[columnIndex - 6] as string));
            }
            _sheet.WriteTextCell(columnIndex, _writer.AddSharedString(_optionColumnHeader));
        }