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); }
/// <summary> /// 初始化国环网页元素探测器。 /// </summary> /// <param name="browser">要探测的网页所在浏览器。</param> /// <param name="attrStringList">需要记录的元素属性列表。</param> public GHElementDetector(WebBrowser browser, IList attrStringList) : base(browser) { _group = null; _excelColumnHeader = attrStringList; _writer = new Office.Excel.ForwardExcelWriter(Path.GetTempFileName()); _writer.Open(); _sheet = _writer.CreateWorksheet() as Office.Excel.ForwardWriteWorksheet; writeExcelHeader(); }
public PrivateDetector(WebBrowser2 browser, string fileName, IList attrStringList) : base(browser) { string tempPath = System.IO.Path.GetTempPath(); _fileName = fileName; _fullName = string.Format("{0}\\{1}", tempPath, fileName); FileInfo info = new FileInfo(_fullName); if (info.Directory.Exists == false) { info.Directory.Create(); } _excelColumnHeader = attrStringList; _writer = new Office.Excel.ForwardExcelWriter(_fullName); _writer.Open(); }
//protected override void onTextElementFinded(IHTMLElement textElement, Stack<IHTMLElement> textNode) //{ // string field = FindField(textNode); //} //protected override void onRadioElementFinded(IHTMLElement radioElement, Stack<IHTMLElement> textNode) //{ // string field = radioElement.getAttribute("value"); //} //protected override void onCheckBoxElementFinded(IHTMLElement checkElement, Stack<IHTMLElement> textNode) //{ // string field = checkElement.getAttribute("value"); //} //protected override void onSubmitElementFinded(IHTMLElement submitElement, IHTMLElement form, Stack<IHTMLElement> textNode) //{ // string field = submitElement.getAttribute("value"); //} //protected override void onSelectElementFinded(IHTMLElement selectElement, Stack<IHTMLElement> textNode) //{ // string field = FindField(textNode); // if (string.IsNullOrEmpty(field)) // field = getFieldFromElement(selectElement); //} //private string getFieldFromElement(IHTMLElement element) //{ // IHTMLElement parent = element.parentElement; // string field = ""; // while (parent != null) // { // if (parent.outerText != null) // { // int index = parent.outerText.IndexOf(element.outerText); // if (index != -1) // field = parent.outerText.Substring(0, index).Trim(_trimChar); // } // if (string.IsNullOrEmpty(field) == false) // break; // parent = parent.parentElement; // } // return field; //} public override void Save() { finishGroup(); Office.Excel.ForwardExcelWriter file = _writer; _writer = new Office.Excel.ForwardExcelWriter(Path.GetTempFileName()); _writer.Open(); _sheet = _writer.CreateWorksheet() as Office.Excel.ForwardWriteWorksheet; writeExcelHeader(); file.Save(); string filename = file.FileName; file.Dispose(); if (File.Exists("generated.xlsx")) { File.Delete("generated.xlsx"); } File.Move(filename, "generated.xlsx"); }
/// <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); } }