{"id":205,"date":"2022-10-10T10:02:48","date_gmt":"2022-10-10T08:02:48","guid":{"rendered":"http:\/\/test.pcbinvestigator.de\/en\/?page_id=205"},"modified":"2022-10-10T13:49:50","modified_gmt":"2022-10-10T11:49:50","slug":"how-to-use-pcb-investigator-in-ms-excel","status":"publish","type":"page","link":"https:\/\/www.pcb-investigator.com\/en\/support\/help-center\/how-to-instructions\/how-to-use-pcb-investigator-in-ms-excel\/","title":{"rendered":"How to use PCB-Investigator in MS Excel"},"content":{"rendered":"\n<p>This example shows how to create a Microsoft Excel plug-in to generate the layerlist with object counts and layertypes in a table.<\/p>\n\n\n\n<p>By opening a new job the Excel table will be filled and all relevant informations are evaluated.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"http:\/\/www.easylogix.de\/download\/HowTo\/ExcelWorkbookExampleCSharp.zip\" target=\"_blank\" rel=\"noopener\">Download Example in C#<\/a><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>public partial class ThisWorkbook\n  {\n    IPCBIWindow window;\n    private void ThisWorkbook_Startup(object sender, System.EventArgs e)\n    {\n      window = IAutomation.CreateNewPCBIWindow(true); \/\/create one instance of PCB-Investigator\n      window.PCBINewJobOpend += new EventHandler(window_PCBINewJobOpend);\n    }\n \n    void window_PCBINewJobOpend(object sender, EventArgs e) \/\/on opening an job we fill the excel sheet\n    {\n      Excel.Sheets sheets;\n      Excel._Worksheet sheet;\n \n      try\n      {\n        try\n        {\n          \/\/Get a reference to the first sheet of the workbook. By changing the index we can write the report in other worksheets\n          sheets = this.Worksheets;\n          sheet = (Excel._Worksheet)sheets.get_Item(1);\n        }\n        catch (Exception exSheet)\n        {\n          MessageBox.Show(exSheet.ToString(), \"Error\", MessageBoxButtons.OK, MessageBoxIcon.Warning);\n \n          return;\n        }\n \n        if (sheet != null)\n        {\n          IStep step = window.GetCurrentStep();\n          IMatrix matrix = window.GetMatrix();\n          if (step != null)\n          {\n            int runIndex =2;\n            sheet.Cells&#91;1, 1].Value = \"Layerlist\";\n            sheet.Cells&#91;1, 2].Value = \"Objectcount\";\n            sheet.Cells&#91;1, 3].Value = \"Layertype\";\n \n            foreach(string layername in step.GetAllLayerNames()) \/\/all layer\n            {\n              sheet.Cells&#91;runIndex, 1].Value = layername;\n              ILayer layer = step.GetLayer(layername);\n              sheet.Cells&#91;runIndex, 2].Value = layer.GetAllLayerObjects().Count; \/\/how much elements on the layer?\n              sheet.Cells&#91;runIndex, 3].Value = matrix.GetMatrixLayerType(layername).ToString(); \/\/which type is this layer?\n              runIndex++;\n            }\n            sheet.Activate(); \/\/show the filled list\n          }\n        }\n      }\n      catch (Exception exError)\n      {\n        MessageBox.Show(exError.ToString(), \"Error\", MessageBoxButtons.OK, MessageBoxIcon.Warning);\n      }\n    }\n \n    private void ThisWorkbook_Shutdown(object sender, System.EventArgs e)\n    {\n      if (window != null)\n        IAutomation.ClosePCBIWindow(window);\n    }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This example shows how to create a Microsoft Excel plug-in to generate the layerlist with object counts and layertypes in a table. By opening a new job the Excel table will be filled and all relevant informations are evaluated. Download Example in C#<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":246,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-205","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/205","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/comments?post=205"}],"version-history":[{"count":1,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/205\/revisions"}],"predecessor-version":[{"id":206,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/205\/revisions\/206"}],"up":[{"embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/pages\/246"}],"wp:attachment":[{"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/media?parent=205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/categories?post=205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pcb-investigator.com\/en\/wp-json\/wp\/v2\/tags?post=205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}