コード例 #1
0
        public void Dispose()
        {
            if (commandButton != null)
            {
                IsDisposed = true;

                if (CurrentCommand != null)
                {
                    commandButton.Click -= CurrentCommand;
                }

                ExcelInterop.Worksheet worksheet = OwnerRange.Worksheet;

                ExcelInterop.OLEObject obj = worksheet.OLEObjects(Name);
                obj.Delete();

                ExcelApplication.ReleaseComObject(obj);
                ExcelApplication.ReleaseComObject(commandButton);
                ExcelApplication.ReleaseComObject(OwnerRange);
                ExcelApplication.ReleaseComObject(worksheet);

                obj           = null;
                commandButton = null;
                OwnerRange    = null;
                worksheet     = null;
            }
        }
コード例 #2
0
        private void add_item(string itemDescription, string idType, bool hasCheckboxes)
        {
            int rowOffset = currentRow * 30 - 102;

            oRng = oSheet.Cells[currentRow, 1];
            oRng.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;
            oRng.Value = " " + itemDescription;
            oRng       = oSheet.Cells[currentRow, 9];
            oRng.Value = idType;

            if (hasCheckboxes)
            {
                //add check boxes
                obj = objs.Add("Forms.Checkbox.1", Missing.Value, Missing.Value, false, false, Missing.Value, Missing.Value, 240, rowOffset, 120, 16);
                obj.Object.Caption   = "SPECIAL M'TL REQUIREMENTS";
                obj.Object.Value     = false;
                obj.Object.Font.Size = 6.5;

                obj = objs.Add("Forms.Checkbox.1", Missing.Value, Missing.Value, false, false, Missing.Value, Missing.Value, 240, rowOffset + 12, 120, 16);
                obj.Object.Caption   = "NORMALIZED M'TL";
                obj.Object.Value     = false;
                obj.Object.Font.Size = 6.5;
            }

            currentRow++;
        }
コード例 #3
0
        public ExcelCheckBox(ExcelInterop.Range range, ExcelCheckBoxDefinition definition)
        {
            OwnerRange        = range;
            OwnerRange.Value2 = null;
            ExcelInterop.Worksheet  worksheet  = null;
            ExcelInterop.OLEObjects oleObjects = null;
            ExcelInterop.OLEObject  oleObject  = null;
            try
            {
                worksheet = OwnerRange.Worksheet;
                Name      = $"ExcelCB{Interlocked.Increment(ref cpt)}";

                oleObjects = worksheet.OLEObjects();
                oleObject  = oleObjects.Add("Forms.CheckBox.1",
                                            Type.Missing,
                                            true,
                                            false,
                                            Type.Missing,
                                            Type.Missing,
                                            Type.Missing,
                                            OwnerRange.Left + 3,
                                            OwnerRange.Top + 1,
                                            12,
                                            12);
                oleObject.Name      = Name;
                oleObject.Placement = ExcelInterop.XlPlacement.xlMove;
                CheckBox            = worksheet.GetType().InvokeMember(Name, BindingFlags.Default | BindingFlags.GetProperty, null, worksheet, null) as ExcelForms.CheckBox;

                CheckBox.SpecialEffect = ExcelForms.fmButtonEffect.fmButtonEffectSunken;
                CheckBox.TripleState   = false;

                CheckBox.Caption              = string.Empty;
                CheckBox.BackColor            = (int)OwnerRange.Interior.Color;
                CheckBox.BackStyle            = ExcelForms.fmBackStyle.fmBackStyleTransparent;
                oleObject.Interior.ColorIndex = -4142;
                CheckBox.AutoSize             = false;

                oleObject = null;
            }
            finally
            {
                if (oleObject != null)
                {
                    ExcelApplication.ReleaseComObject(oleObject);
                }
                if (oleObjects != null)
                {
                    ExcelApplication.ReleaseComObject(oleObjects);
                }
                if (worksheet != null)
                {
                    ExcelApplication.ReleaseComObject(worksheet);
                }

                oleObject  = null;
                oleObjects = null;
                worksheet  = null;
            }
        }
コード例 #4
0
        public ExcelButton(ExcelInterop.Range range, ExcelButtonDefinition definition)
        {
            OwnerRange        = range;
            OwnerRange.Value2 = null;
            ExcelInterop.Worksheet  worksheet  = null;
            ExcelInterop.OLEObjects oleObjects = null;
            ExcelInterop.OLEObject  obj        = null;

            try
            {
                worksheet = OwnerRange.Worksheet;
                Name      = $"ExcelBtn{Interlocked.Increment(ref cpt)}";

                oleObjects = worksheet.OLEObjects();
                obj        = oleObjects.Add("Forms.CommandButton.1",
                                            Type.Missing,
                                            false,
                                            false,
                                            Type.Missing,
                                            Type.Missing,
                                            Type.Missing,
                                            OwnerRange.Left + definition.X,
                                            OwnerRange.Top + definition.Y,
                                            definition.W == 0 ? OwnerRange.Width : definition.W,
                                            definition.H == 0 ? OwnerRange.Height : definition.H);

                obj.Name = Name;
                object s = worksheet.GetType().InvokeMember(Name, BindingFlags.Default | BindingFlags.GetProperty, null, worksheet, null);
                commandButton           = s as ExcelForms.CommandButton;
                commandButton.FontName  = "Arial";
                commandButton.Font.Size = 8;
                commandButton.Caption   = definition.Label;
                //if (excelTemplateDefinition.W == 0 && excelTemplateDefinition.H == 0)
                //    commandButton.AutoSize = true;
                obj.Placement = ExcelInterop.XlPlacement.xlMove;
            }
            finally
            {
                if (obj != null)
                {
                    ExcelApplication.ReleaseComObject(obj);
                }
                if (oleObjects != null)
                {
                    ExcelApplication.ReleaseComObject(oleObjects);
                }
                if (worksheet != null)
                {
                    ExcelApplication.ReleaseComObject(worksheet);
                }
                obj        = null;
                oleObjects = null;
                worksheet  = null;
            }
        }
コード例 #5
0
ファイル: Traveler.cs プロジェクト: ykromsky/Blueprint
        private void line_hold_points()
        {
            oSheet.Cells[currentRow, 1].Value = "HOLD POINTS SET BY";
            oSheet.Cells[currentRow, 9].Value = "X";
            currentRow++;

            oSheet.Cells[currentRow, 1].Value = "DRAWINGS REVIEWED/ACCEPTED";
            oSheet.Cells[currentRow, 9].Value = "X";
            currentRow++;

            oSheet.Cells[currentRow, 1].Value = "CALCULATIONS REVIEWED/ON FILE";
            oSheet.Cells[currentRow, 9].Value = "X";
            currentRow++;

            obj = objs.Add("Forms.Checkbox.1", Missing.Value, Missing.Value, false, false, Missing.Value, Missing.Value, 250, 122, 100, 16);
            obj.Object.Caption   = "STANDARD CALCS USED";
            obj.Object.Value     = true;
            obj.Object.Font.Size = 8;
        }
コード例 #6
0
ファイル: ExcelPicture.cs プロジェクト: lanicon/Etk.Excel
        public void Dispose()
        {
            if (CheckBox != null)
            {
                IsDisposed = true;
                if (CurrentOnClick != null)
                {
                    CheckBox.Click -= CurrentOnClick;
                }

                ExcelInterop.Worksheet worksheet = OwnerRange.Worksheet;
                ExcelInterop.OLEObject oleObject = worksheet.OLEObjects(Name);
                oleObject.Delete();

                ExcelApplication.ReleaseComObject(oleObject);
                ExcelApplication.ReleaseComObject(OwnerRange);
                ExcelApplication.ReleaseComObject(worksheet);
                ExcelApplication.ReleaseComObject(CheckBox);
                oleObject  = null;
                OwnerRange = null;
                worksheet  = null;
                CheckBox   = null;
            }
        }
コード例 #7
0
ファイル: Traveler.cs プロジェクト: ykromsky/Blueprint
        private void title_block1()
        {
            //LINE 1
            oRng = oSheet.Range[oSheet.Cells[currentRow, 1], oSheet.Cells[currentRow, 8]];
            oRng.Merge();
            oRng.Font.Bold = true;
            oRng.Font.Size = 14;
            oRng.Value     = "REFRIGERATION VALVES AND SYSTEMS VESSEL TRAVELER";

            oRng = oSheet.Cells[currentRow, 9];
            oRng.HorizontalAlignment = Excel.XlHAlign.xlHAlignRight;
            oRng.Value = "SHT";

            oRng       = oSheet.Cells[currentRow, 10];
            oRng.Value = 1;

            oRng = oSheet.Range[oSheet.Cells[currentRow, 11], oSheet.Cells[currentRow, 12]];
            oRng.Merge();
            oRng.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;
            oRng.Value = "OF";

            oRng = oSheet.Cells[currentRow, 13];
            oRng.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;
            oRng.Value = sheet_count;

            currentRow++;

            //LINE 2
            oRng = oSheet.Range[oSheet.Cells[currentRow, 1], oSheet.Cells[currentRow, 2]];
            oRng.Merge();
            oRng.Font.Bold           = true;
            oRng.HorizontalAlignment = Excel.XlHAlign.xlHAlignRight;
            oRng.Value = "DRAWING #";

            oRng = oSheet.Range[oSheet.Cells[currentRow, 3], oSheet.Cells[currentRow, 4]];
            oRng.Merge();
            oRng.Font.Bold           = true;
            oRng.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;
            oRng.Value = drawing_number;

            oRng = oSheet.Range[oSheet.Cells[currentRow, 5], oSheet.Cells[currentRow, 6]];
            oRng.Merge();
            oRng.Font.Bold           = true;
            oRng.HorizontalAlignment = Excel.XlHAlign.xlHAlignRight;
            oRng.Value = "REV.";

            oRng = oSheet.Range[oSheet.Cells[currentRow, 7], oSheet.Cells[currentRow, 8]];
            oRng.Merge();
            oRng.Font.Bold           = true;
            oRng.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;
            oRng.Value = revision_number;

            oRng = oSheet.Range[oSheet.Cells[currentRow, 9], oSheet.Cells[currentRow, 10]];
            oRng.Merge();
            oRng.Font.Bold           = true;
            oRng.HorizontalAlignment = Excel.XlHAlign.xlHAlignRight;
            oRng.Value = "SERIAL #";

            oRng = oSheet.Range[oSheet.Cells[currentRow, 11], oSheet.Cells[currentRow, 13]];
            oRng.Merge();
            oRng.Font.Bold           = true;
            oRng.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;
            oRng.Value = serial_number;

            currentRow++;

            //LINE 3
            oRng = oSheet.Range[oSheet.Cells[currentRow, 1], oSheet.Cells[currentRow, 6]];
            oRng.Merge();

            obj = objs.Add("Forms.Checkbox.1", Missing.Value, Missing.Value, false, false, Missing.Value, Missing.Value, 5, 41, 120, 16);
            obj.Object.Caption   = "SPECIAL M'TL REQUIREMENTS";
            obj.Object.Value     = false;
            obj.Object.Font.Size = 8;

            obj = objs.Add("Forms.Checkbox.1", Missing.Value, Missing.Value, false, false, Missing.Value, Missing.Value, 160, 41, 90, 16);
            obj.Object.Caption   = "NORMALIZED M'TL";
            obj.Object.Value     = false;
            obj.Object.Font.Size = 8;

            obj = objs.Add("Forms.Checkbox.1", Missing.Value, Missing.Value, false, false, Missing.Value, Missing.Value, 262, 41, 15, 16);
            obj.Object.Caption   = "";
            obj.Object.Value     = true;
            obj.Object.Font.Size = 8;

            oRng = oSheet.Range[oSheet.Cells[currentRow, 7], oSheet.Cells[currentRow, 13]];
            oRng.Merge();
            oRng.Font.Size           = 8;
            oRng.WrapText            = true;
            oRng.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;
            oRng.Value = special_note;

            currentRow++;

            //LINE 4
            oRng           = oSheet.Cells[currentRow, 1];
            oRng.Value     = "DESCRIBE SPECIFIC ITEMS TO BE INSPECTED";
            oRng.Font.Bold = true;

            oRng       = oSheet.Cells[currentRow, 9];
            oRng.Value = "X";

            oRng           = oSheet.Cells[currentRow, 10];
            oRng.Font.Size = 10;
            oRng.Value     = "QC HOLD";

            oRng       = oSheet.Cells[currentRow, 12];
            oRng.Value = "X";

            oRng           = oSheet.Cells[currentRow, 13];
            oRng.Font.Size = 10;
            oRng.Value     = "A/I HOLD";

            currentRow++;
        }