예제 #1
0
        //-------------------------------------------------------------------------
        /* List Workbooks objects from opened Excel windows */
        public static List <Excel.Workbook> GetOpenedXls()
        {
            List <Excel.Workbook> wbooks = new List <Excel.Workbook>();
            List <Process>        procs  = new List <Process>();

            procs.AddRange(Process.GetProcessesByName("excel"));

            foreach (Process p in procs)
            {
                if ((int)p.MainWindowHandle > 0)
                {
                    int childWindow = 0;
                    var cb          = new EnumChildCallback(EnumChildProc);
                    EnumChildWindows((int)p.MainWindowHandle, cb, ref childWindow);

                    if (childWindow > 0)
                    {
                        const uint   OBJID_NATIVEOM = 0xFFFFFFF0;
                        Guid         IID_IDispatch  = new Guid("{00020400-0000-0000-C000-000000000046}");
                        Excel.Window window         = null;
                        if (AccessibleObjectFromWindow(childWindow, OBJID_NATIVEOM, IID_IDispatch.ToByteArray(), ref window) >= 0)
                        {
                            wbooks.AddRange(window.Application.Workbooks.Cast <Excel.Workbook>());
                        }
                    }
                }
            }
            return(wbooks);
        }
예제 #2
0
        public void OnNOCButton(Office.IRibbonControl control)
        {
            Excel.Window      window        = control.Context;
            Excel.Application myApplication = window.Application;

            //get current user name
            string userName = Environment.UserName;

            MessageBox.Show("Generate NOC.");
            Word.Application app      = new Word.Application();
            Document         document = app.Documents.Open(@"C:\\Users\\" + userName + "\\Desktop\\Addin Development\\Templates\\NOC.docx");

            //should do this again in case the names changed when preparing NOCs
            //getting delegation list
            LinkedList <String> guestList = new LinkedList <string>();
            LinkedList <String> hostList  = new LinkedList <string>();

            initialiseGuestList(guestList, myApplication);
            initialiseHostList(hostList, myApplication);

            //update involvement list at Annex
            updateNocInvolvement(hostList, guestList, document);
            replacePlaceholder(app, "<<HOST_NAME>>", getInfoFromExcel(myApplication, "hostHOD").ToString().ToUpper());
            replacePlaceholder(app, "<<GUEST_NAME>>", getInfoFromExcel(myApplication, "guestHOD").ToString().ToUpper());
            replacePlaceholder(app, "<<COUNTRY_NAME>>", getInfoFromExcel(myApplication, "country"));

            document.SaveAs2(@"C:\\Users\\" + userName + "\\Desktop\\Addin Development\\NOC.docx");
            document.Close();
            app.Quit();
        }
예제 #3
0
        private void Excel_WindowDeactivate(Excel.Workbook workbook, Excel.Window window)
        {
#if DEBUG
            Log.Logger.Debug("WindowDeactivate");
#endif
            //this.Update();
        }
예제 #4
0
 /////////////////////////////////////////////////////////
 /// 创建区
 /////////////////////////////////////////////////////////
 public XlWorkbookHelper()
 {
     app = Globals.ThisAddIn.Application;
     win = app.ActiveWindow;
     //pan = win.ActivePane;
     //cell = win.ActiveCell;
 }
 static void Main(string[] args)
 {
     Excel.Application app = new Excel.Application();
     EnumChildCallback cb;
     List<Process> procs = new List<Process>();
     procs.AddRange(Process.GetProcessesByName("excel"));
     foreach (Process p in procs)
     {
         if ((int)p.MainWindowHandle > 0)
         {
             int childWindow = 0;
             cb = new EnumChildCallback(EnumChildProc);
             EnumChildWindows((int)p.MainWindowHandle, cb, ref childWindow);
             if (childWindow > 0)
             {
                 const uint OBJID_NATIVEOM = 0xFFFFFFF0;
                 Guid IID_IDispatch = new Guid("{00020400-0000-0000-C000-000000000046}");
                 Excel.Window window = null;
                 int res = AccessibleObjectFromWindow(childWindow, OBJID_NATIVEOM, IID_IDispatch.ToByteArray(), ref window);
                 if (res >= 0)
                 {
                     app = window.Application;
                     Console.WriteLine(app.Name);
                 }
             }
         }
     }
 }
예제 #6
0
 private void FreezeFrames()
 {
     Excel.Window activeWindow = Globals.ThisWorkbook.Application.ActiveWindow;
     activeWindow.SplitRow    = 4;
     activeWindow.SplitColumn = 3;
     activeWindow.FreezePanes = true;
 }
예제 #7
0
 private void Application_WindowResize(Excel.Workbook Wb, Excel.Window Wn)
 {
     if (Ribbon1.isnewpressed)
     {
         xlribbon.LightShine();
     }
 }
예제 #8
0
        /// <summary>
        /// Searches for the the excel interop from the provided process.
        /// </summary>
        /// <param name="p">The process.</param>
        /// <returns>Excel.Application.</returns>
        /// <exception cref="System.Exception">
        /// Excel Main Window Not Found
        /// or
        /// Excel Child Window Not Found
        /// or
        /// Accessible Object Not FOund
        /// </exception>
        private Excel.Application SearchExcelInterop(Process p)
        {
            Excel.Window ptr  = null;
            int          hwnd = 0;

            int hWndParent = (int)p.MainWindowHandle;

            if (hWndParent == 0)
            {
                throw new Exception("Excel Main Window Not Found");
            }

            EnumChildWindows(hWndParent, EnumChildFunc, ref hwnd);
            if (hwnd == 0)
            {
                throw new Exception("Excel Child Window Not Found");
            }

            int hr = AccessibleObjectFromWindow(hwnd, DW_OBJECTID, rrid.ToByteArray(), ref ptr);

            if (hr < 0)
            {
                throw new Exception("Accessible Object Not FOund");
            }

            return(ptr.Application);
        }
예제 #9
0
 void App_WindowActivate(Excel.Workbook Wb, Excel.Window wn)
 {
     SetGlobalDirectory();
     SetDiffRegionMenu();
     jsonFile = Path.GetDirectoryName(app.ActiveWorkbook.FullName) + string.Format("/../../../Excel/{0}/{1}.{2}", I8N_DIRECTORY, Path.GetFileNameWithoutExtension(app.ActiveWorkbook.Name), "json");
     Globals.Ribbons.Ribbon1.button17.Enabled   = File.Exists(jsonFile);
     Properties.Settings.Default.autoLoadFormat = false;
     Globals.Ribbons.Ribbon1.checkBox1.Checked  = Properties.Settings.Default.autoLoadFormat;
 }
예제 #10
0
 private void ImporterRibbon_Load(object sender, RibbonUIEventArgs e)
 {
     this.select = new FolderSelection();
     this.select.ribbon = this;
     this.excelWin = Globals.Program.Application.ActiveWindow;
     this.import = new HeaderImport(excelWin);
     this.calc = new CalcImport(this);
     this.openFile = new System.Windows.Forms.OpenFileDialog();
     this.openFile.Filter = "Excel files(*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm";
 }
예제 #11
0
 private void ImporterRibbon_Load(object sender, RibbonUIEventArgs e)
 {
     this.select          = new FolderSelection();
     this.select.ribbon   = this;
     this.excelWin        = Globals.Program.Application.ActiveWindow;
     this.import          = new HeaderImport(excelWin);
     this.calc            = new CalcImport(this);
     this.openFile        = new System.Windows.Forms.OpenFileDialog();
     this.openFile.Filter = "Excel files(*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm";
 }
예제 #12
0
 private static void ApplicationOnWindowActivate(Excel.Workbook wb, Excel.Window wn)
 {
     try
     {
         WakaTime.HandleActivity(wb.FullName, false, string.Empty);
     }
     catch (Exception ex)
     {
         WakaTime.Logger.Error("ApplicationOnWindowActivate", ex);
     }
 }
예제 #13
0
        private void Application_WindowActivate(Excel.Workbook Wb, Excel.Window Wn)
        {
            // load ADS query task pane control
            //throw new NotImplementedException();

            myCustomTaskPane       = this.CustomTaskPanes.Add(new crlADSQuery(), "SQL Database Functions");
            myCustomTaskPane.Width = 360;

            Globals.Ribbons.ribbonS2088Reserving.ADSQuery.Checked = myCustomTaskPane.Visible;
            myCustomTaskPane.VisibleChanged += MyCustomTaskPane_VisibleChanged;
        }
예제 #14
0
 public HeaderImport(Excel.Window window)
 {
     if (excelWin != null)
     {
         excelWin = window;
     }
     else
     {
         excelWin = Globals.Program.Application.ActiveWindow;
     }
     m_parseState = new ParserState();
 }
예제 #15
0
        public void ExportPays(String sheetName, Excel.Workbook targetBook)
        {
            // stop screen updates - reduces run time by nearly a factor of 10
            m_symbolList.Sort();

            Globals.Program.Application.ScreenUpdating = false;
            Excel.Window excelWin = Globals.Program.Application.ActiveWindow;

            if (targetBook == null)
            {
                targetBook = excelWin.Application.ActiveWorkbook;
                if (targetBook == null)
                {
                    System.Windows.Forms.MessageBox.Show("No source Workbook or Worksheet available.", "Error - No source.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    return;
                }
            }

            int sheetIndex = getSheetIndex("Wins Combination", targetBook);

            Excel.Worksheet targetSheet = targetBook.Worksheets[sheetIndex];

            // fill in symbol table
            String payStartCell = "R6";
            String cell         = payStartCell;
            String col          = parseCol(payStartCell);
            int    row          = 0;

            for (int i = 0; i < 4; i++)
            {
                row = parseRow(payStartCell);
                foreach (String symbol in m_symbolList)
                {
                    OutputCell(targetSheet, cell, symbol);
                    row++;
                    cell = col + row.ToString();
                }
                row  = parseRow(payStartCell);
                col  = incrementColumn(cell);
                cell = col + row.ToString();
            }

            // fill in pay table
            if (m_linePays.LinePays.Count > 1)
            {
                m_linePays.SendToWorksheet(targetBook, targetSheet);
            }
            else
            {
                m_scatterPays.SendToWorksheet(targetBook, targetSheet);
            }
        }
            public bool TryFindExcelWindow(IntPtr hwndChild, [CanBeNull] out Excel.Window ptr)
            {
                // If we found an accessible child window, call
                // AccessibleObjectFromWindow, passing the constant
                // OBJID_NATIVEOM (defined in winuser.h) and
                // IID_IDispatch - we want an IDispatch pointer
                // into the native object model.
                const uint OBJID_NATIVEOM = 0xFFFFFFF0;

                HResult hr = NativeMethods.AccessibleObjectFromWindow(hwndChild, OBJID_NATIVEOM, ref IID_IDispatch, out ptr);

                return(hr.Succeeded);
            }
예제 #17
0
 void Application_WindowActivate(Excel.Workbook wb, Excel.Window Wn)
 {
     RemoveOrphanedTaskPanes();
     try
     {
         DocumentProperties prps;
         prps = (DocumentProperties)Globals.ThisAddIn.Application.ActiveWorkbook.CustomDocumentProperties;
         CustomTaskPane ctp = Globals.ThisAddIn.CustomTaskPanes.Where(x => x.Control.Name == prps["customTaskPaneName"].Value.ToString()).FirstOrDefault();
         if (ctp != null && Globals.Ribbons.Ribbon1.toggleButton1.Checked)
         {
             ctp.Visible = true;
         }
     }
     catch { }
 }
예제 #18
0
 public bool GetIsConfidential(Office.IRibbonControl control)
 {
     Excel.Window window = control.Context;
     if (window != null)
     {
         Excel.Worksheet sheet  = window.ActiveSheet;
         String          strVal = (sheet.Cells[1, 1].Value2 ?? "").ToString();
         return(strVal.Equals("1"));
     }
     else
     {
         // When the application is booted for the first time this callback will be invoked, but control.Context will be null.
         // In this case, make the control's value blank (it shouldn't matter, because the user can't see the home tab at this point).
         return(false);
     }
 }
예제 #19
0
        public override void SendToWorksheet(Excel.Worksheet targetSheet, String StartCell, int startReel, int reelWidth, bool skipColumns = false, bool fullOutput = false)
        {
            // Fill in a set of cells with this reelset's values
            // The skipColumns parameter will skip columns between reels, starting in the target cell.
            // The fullOutput parameter will include the weight and nudge values in separate columns in the output.  If
            // skipColumns is specified a column will be skipped between reels.

            if (startReel < 0 || (startReel + reelWidth) >= m_reels.Count)
            {
                MessageBox.Show("SendToWorksheet() - invalid range specified");
                return;
            }

            // stop screen updates - reduces run time by nearly a factor of 10
            Globals.Program.Application.ScreenUpdating = false;
            if (excelWin == null)
            {
                excelWin = Globals.Program.Application.ActiveWindow;
            }

            targetBook = excelWin.Application.ActiveWorkbook;
            if (targetBook == null)
            {
                System.Windows.Forms.MessageBox.Show("No source Workbook or Worksheet available.", "Error - No source.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }

            String col = parseCol(StartCell);
            int    row = parseRow(StartCell);

            if (row < 1)
            {
                row = 1;
            }
            String cell = col + row.ToString();

            for (int i = startReel; i < (startReel + reelWidth); i++)
            {
                m_reels[i].OutputColumn(targetSheet, cell, false);
                cell = incrementColumn(cell);
                if (skipColumns)
                {
                    cell = incrementColumn(cell);
                }
            }
            Globals.Program.Application.ScreenUpdating = true;
        }
예제 #20
0
        private static Excel.Worksheet FindActiveSheet(Excel.Windows windows, COMObjectsHelper comHelper, string title)
        {
            Excel.Window matchingWindow = null;

            for (var i = 1; i <= windows.Count; i++)
            {
                var window = comHelper.Register(() => windows[i]);

                if (title.Contains(window.Caption))
                {
                    matchingWindow = window;
                    break;
                }
            }

            return(comHelper.Register(() => matchingWindow?.ActiveSheet));
        }
예제 #21
0
        private void AddFinalTouches(Excel.Worksheet xlSheet)
        {
            Excel.Range firstCell = xlSheet.Cells[1, 1] as Excel.Range;
            if (firstCell != null)
            {
                Excel.Range titleRow = firstCell.EntireRow as Excel.Range;
                titleRow.RowHeight *= 2;
                titleRow.AutoFilter(Field: 1, Operator: Excel.XlAutoFilterOperator.xlAnd);
                titleRow.AutoFit();
                Marshal.ReleaseComObject(titleRow);

                Excel.Window xlWindow = this.xlApp.ActiveWindow;
                xlWindow.SplitRow    = 1;
                xlWindow.FreezePanes = true;
                Marshal.ReleaseComObject(xlWindow);
            }
            Marshal.ReleaseComObject(firstCell);
        }
예제 #22
0
 public string GetWorkbookName(Office.IRibbonControl control)
 {
     // This callback is hooked up to the "Workbook name" textbox on the custom ribbon.
     // Excel will take care of firing it at the right time, and you can use the "control.Context"
     // object to get all the necessary information about the current workbook.
     Excel.Window window = control.Context;
     if (window != null)
     {
         Excel.Worksheet sheet = window.ActiveSheet;
         Excel.Workbook  book  = sheet.Parent;
         return(book.Name);
     }
     else
     {
         // When the application is booted for the first time this callback will be invoked, but control.Context will be null.
         // In this case, make the control's value blank (it shouldn't matter, because the user can't see the home tab at this point).
         return("");
     }
 }
        public static void StartLoading()
        {
            Excel.Application app          = Globals.ThisAddIn.Application;
            Excel.Window      activeWindow = app.ActiveWindow;
            Excel.Worksheet   currentSheet = app.ActiveSheet;
            Excel.Range       visibleRange = activeWindow.VisibleRange;

            System.Drawing.Size textSize = System.Windows.Forms.TextRenderer.MeasureText("Loading please wait ...", new System.Drawing.Font("Arial", 22));

            Excel.Shapes shapes = currentSheet.Shapes;

            float left = Convert.ToSingle(visibleRange.Width / 2) - textSize.Width / 2;
            float top  = Convert.ToSingle(visibleRange.Height / 2) - (textSize.Height / 2 + 40);

            if (visibleRange.Row != 1)
            {
                // Add any top margin if there is a scroll top
                Excel.Range invisibleRangeOnTop = currentSheet.Range[currentSheet.Cells[1, 1], currentSheet.Cells[visibleRange.Row - 1, 1]];
                top += invisibleRangeOnTop.Height;
            }

            if (visibleRange.Column != 1)
            {
                // Add any left margin if there is a scroll to right
                Excel.Range invisibleRangeAside = currentSheet.Range[currentSheet.Cells[1, 1], currentSheet.Cells[1, visibleRange.Column - 1]];
                left += invisibleRangeAside.Width;
            }

            _loadingText = shapes.AddTextEffect(Office.MsoPresetTextEffect.msoTextEffect16,
                                                "Loading please wait ...",
                                                "Arial",
                                                22,
                                                Office.MsoTriState.msoFalse,
                                                Office.MsoTriState.msoFalse,
                                                left,
                                                top
                                                );

            app.Interactive = false;
        }
        public ExcelApplicationRetriever(int winHandle)
        {
            // We need to enumerate the child windows to find one that
            // supports accessibility. To do this, instantiate the
            // delegate and wrap the callback method in it, then call
            // EnumChildWindows, passing the delegate as the 2nd arg.
            if (winHandle != 0)
            {
                int hwndChild = 0;
                cb = new EnumChildCallback(EnumChildProc);
                EnumChildWindows(winHandle, cb, ref hwndChild);

                // If we found an accessible child window, call
                // AccessibleObjectFromWindow, passing the constant
                // OBJID_NATIVEOM (defined in winuser.h) and
                // IID_IDispatch - we want an IDispatch pointer
                // into the native object model.
                if (hwndChild != 0)
                {
                    const uint OBJID_NATIVEOM = 0xFFFFFFF0;
                    Guid       IID_IDispatch  = new Guid(
                        "{00020400-0000-0000-C000-000000000046}");
                    Excel.Window ptr = null;

                    int hr = AccessibleObjectFromWindow(
                        hwndChild, OBJID_NATIVEOM,
                        IID_IDispatch.ToByteArray(), ref ptr);
                    if (hr >= 0)
                    {
                        // If we successfully got a native OM
                        // IDispatch pointer, we can QI this for
                        // an Excel Application (using the implicit
                        // cast operator supplied in the PIA).
                        xl = ptr.Application;
                    }
                }
            }
        }
예제 #25
0
        public virtual void SendToWorksheet(Excel.Worksheet targetSheet, String StartCell, bool skipColumns = false, bool fullOutput = false)
        {
            // Fill in a set of cells with this reelset's values
            // The skipColumns parameter will skip columns between reels, starting in the target cell.
            // The fullOutput parameter will include the weight and nudge values in separate columns in the output.  If
            // skipColumns is specified a column will be skipped between reels.

            // stop screen updates - reduces run time by nearly a factor of 10
            Globals.Program.Application.ScreenUpdating = false;
            if (excelWin == null)
            {
                excelWin = Globals.Program.Application.ActiveWindow;
            }

            targetBook = excelWin.Application.ActiveWorkbook;
            if (targetBook == null)
            {
                System.Windows.Forms.MessageBox.Show("No source Workbook or Worksheet available.", "Error - No source.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }

            String cell = StartCell;
            String col  = parseCol(StartCell);
            int    row  = parseRow(StartCell);

            foreach (Reel reel in m_reels)
            {
                reel.OutputColumn(targetSheet, cell, false);
                col  = incrementColumn(col);
                cell = col + row.ToString();
                if (skipColumns)
                {
                    cell = incrementColumn(col) + row.ToString();
                }
            }
        }
예제 #26
0
        private void btnFileMerge_Click(object sender, RibbonControlEventArgs e)
        {
            List <string> files = null;

            using (var dialog = new OpenFileDialog())
            {
                dialog.Multiselect = true;
                dialog.Filter      = "Excel (*.xlsx)|*.xlsx";
                var result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    files = new List <string>(dialog.FileNames);
                }
            }

            if (files == null)
            {
                return;
            }

            Excel.Window      window      = (Excel.Window)e.Control.Context;
            Excel.Application application = window.Application;
            Excel.Workbook    activeBook  = application.ActiveWorkbook;
            application.ScreenUpdating = false;
            for (int i = 0; i < files.Count; i++)
            {
                string          path     = files[i];
                string          filename = Path.GetFileNameWithoutExtension(path);
                Excel.Workbook  book     = application.Workbooks.Open(path);
                Excel.Worksheet sheet    = book.Sheets[1];
                sheet.Name = filename;
                sheet.Copy(Type.Missing, activeBook.Sheets[1]);
                book.Close(false);
            }
            application.ScreenUpdating = true;
        }
예제 #27
0
        public virtual void SendToWorksheet(Excel.Worksheet targetSheet, String StartCell, int startReel, int reelWidth, bool skipColumns = false, bool fullOutput = false)
        {
            // Fill in a set of cells with this reelset's values
            // The skipColumns parameter will skip columns between reels, starting in the target cell.
            // The fullOutput parameter will include the weight and nudge values in separate columns in the output.  If
            // skipColumns is specified a column will be skipped between reels.

            if (startReel < 0 || (startReel + reelWidth) >= m_reels.Count)
            {
                MessageBox.Show("SendToWorksheet() - invalid range specified");
                return;
            }

            // stop screen updates - reduces run time by nearly a factor of 10
            Globals.Program.Application.ScreenUpdating = false;
            if (excelWin == null)
                excelWin = Globals.Program.Application.ActiveWindow;

            targetBook = excelWin.Application.ActiveWorkbook;
            if (targetBook == null)
            {
                System.Windows.Forms.MessageBox.Show("No source Workbook or Worksheet available.", "Error - No source.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }

            String col = parseCol(StartCell);
            int row = parseRow(StartCell);
            if (row < 1)
                row = 1;
            String cell = col + row.ToString();
            for (int i = startReel; i < (startReel + reelWidth); i++)
            {
                m_reels[i].OutputColumn(targetSheet, cell, false);
                cell = incrementColumn(cell);
                if (skipColumns)
                    cell = incrementColumn(cell);
            }
            Globals.Program.Application.ScreenUpdating = true;
        }
예제 #28
0
 private void Application_WindowDeactivate(Excel.Workbook wb, Excel.Window wn)
 {
     ProcessCleanQueue(true);
 }
예제 #29
0
        public void importReels()
        {
            // CYA buddy - when the add-ins load there is apparently no active window, so
            // catch that here.
            // stop screen updates - reduces run time by nearly a factor of 10
            Globals.Program.Application.ScreenUpdating = false;
            if (excelWin == null)
                excelWin = Globals.Program.Application.ActiveWindow;
            if (source.ActiveSheet == null)
            {
                System.Windows.Forms.MessageBox.Show("No source Workbook or Worksheet available.", "Error - No source.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }
            sourceSheet = source.ActiveSheet;

            // Copy the parsed reels to the match sheet
            String start = startCell.Address.ToString().Replace("$", "");
            if (startCell.Column > 5 || !checkValue(source, source.ActiveSheet, start))
            {
                System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Starting cell appears to be invalid.  Continue?", "Check Starting Cell", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Information);
                if (result == System.Windows.Forms.DialogResult.No)
                {
                    Globals.Program.Application.ScreenUpdating = true;
                    return;
                }
            }
            int startRow = 1;
            try
            {
                startRow = System.Convert.ToInt32(start.Substring(1));
            }
            catch (Exception convEx)
            {
                System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("You appear to have more than one selected starting cell.  Please select a single starting cell and try again.", "Check Starting Cell", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                Globals.Program.Application.ScreenUpdating = true;
                return;
            }
            String end = parseCol(start) + (startRow + 300).ToString();

            // We know this is one reel, so copy it
            copyRange(sourceSheet, targetSheet, start, end, "B8");
            // Now we start looking for more reels.  Frequently document reels are separated by
            // blank columns so we can't just march on down the row.
            start = incrementColumn(start);
            while (!checkValue(source, sourceSheet, start))
            {
                start = incrementColumn(start);
            }
            end = parseCol(start) + (startRow + 300).ToString();
            copyRange(sourceSheet, targetSheet, start, end, "C8");

            start = incrementColumn(start);
            while (!checkValue(source, sourceSheet, start))
            {
                start = incrementColumn(start);
            }
            end = parseCol(start) + (startRow + 300).ToString();
            copyRange(sourceSheet, targetSheet, start, end, "D8");

            start = incrementColumn(start);
            while (!checkValue(source, sourceSheet, start))
            {
                start = incrementColumn(start);
            }
            end = parseCol(start) + (startRow + 300).ToString();
            copyRange(sourceSheet, targetSheet, start, end, "E8");

            start = incrementColumn(start);
            while (!checkValue(source, sourceSheet, start))
            {
                start = incrementColumn(start);
            }
            end = parseCol(start) + (startRow + 300).ToString();
            copyRange(sourceSheet, targetSheet, start, end, "F8");

            Globals.Program.Application.ScreenUpdating = true;

            this.source.Close();
            this.ribbon.EnableCalcImport(false);
        }
예제 #30
0
 public void SetWindow(Excel.Workbook wb, Excel.Window wn)
 {
     SelectedWindow = wn;
 }
예제 #31
0
 public CalcImport(ImporterRibbon parent)
 {
     excelWin = Globals.Program.Application.ActiveWindow;
     ribbon = parent;
 }
예제 #32
0
        public override void SendToWorksheet(Excel.Worksheet targetSheet, String StartCell, bool skipColumns = false, bool fullOutput = false)
        {
            // Fill in a set of cells with this reelset's values
            // The skipColumns parameter will skip columns between reels, starting in the target cell.
            // The fullOutput parameter will include the weight and nudge values in separate columns in the output.  If
            // skipColumns is specified a column will be skipped between reels.

            // stop screen updates - reduces run time by nearly a factor of 10
            Globals.Program.Application.ScreenUpdating = false;
            if (excelWin == null)
                excelWin = Globals.Program.Application.ActiveWindow;

            targetBook = excelWin.Application.ActiveWorkbook;
            if (targetBook == null)
            {
                System.Windows.Forms.MessageBox.Show("No source Workbook or Worksheet available.", "Error - No source.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }

            String cell = StartCell;
            String col = parseCol(StartCell);
            int row = parseRow(StartCell);
            foreach( BallyReel reel in m_reels )
            {
                reel.OutputColumn(targetSheet, cell, false);
                col = incrementColumn(col);
                cell = col + row.ToString();
                if (skipColumns)
                    cell = incrementColumn(col) + row.ToString();
            }
        }
예제 #33
0
 public static extern int AccessibleObjectFromWindow(
     int hwnd, uint dwObjectID, byte[] riid,
     ref Excel.Window ptr);
예제 #34
0
 void AppEvents_WindowActivate(Excel.Workbook wb, Excel.Window wn)
 {
     Log.WriteLog(string.Format("Window {0} activated with workbook {1}", wn.Caption, wb.Name));
 }
예제 #35
0
 public HeaderImport(Excel.Window window)
 {
     if (excelWin != null)
         excelWin = window;
     else
         excelWin = Globals.Program.Application.ActiveWindow;
     m_parseState = new ParserState();
 }
 private void WindowDeactivated(Workbook wb, Microsoft.Office.Interop.Excel.Window wn)
 {
     ExcelManager.RemoveInstance(Id);
     Close();
 }
예제 #37
0
        public void importFolder(String folder, ReelDataType type = ReelDataType.SHFL)
        {
            // CYA buddy - when the add-ins load there is apparently no active window, so
            // catch that here.
            if (excelWin == null)
                excelWin = Globals.Program.Application.ActiveWindow;
            target = Globals.Program.Application.ActiveWorkbook;
            // get a list of all header files in the selected directory
            currentFolder = folder;
            // This is the starting row for the Game Info worksheet reel match summary.
            currentReelSet = 7;
            IComparer comp = new fileSorter();

            if ( type == ReelDataType.SHFL ) // Equinox/SLV reel definition header files
                fileList = Directory.GetFiles(currentFolder, "*.h");
            if ( type == ReelDataType.BALLY ) // Alpha II paytable.cfg file
                fileList = Directory.GetFiles(currentFolder, "paytable.cfg");

            Array.Sort(fileList, comp);
            if (fileList.Length == 0)
            {
                System.Windows.Forms.MessageBox.Show("There are no header files in the selected folder.", "No Header Files Found.", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }

            if (type == ReelDataType.SHFL)
            {
                // run down the list and import each file into an Excel sheet
                for (int index = 0; index < fileList.Length; index++)
                {
                    String name = trimName(fileList.GetValue(index).ToString()) + " Match";
                    if (findSheet(name))
                    {
                        System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("These headers have already been imported.  Would you like to import them again?", "Re-import headers?", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Information);
                        if (result == System.Windows.Forms.DialogResult.No)
                            return;
                    }

                    // copy the match sheet template to a new worksheet
                    copyMatchSheet(fileList.GetValue(index).ToString());
                    // copy the pay sheet template to a new worksheet
                    copyPaySheet(fileList.GetValue(index).ToString());
                    // stop screen updates - reduces run time by nearly a factor of 10
                    Globals.Program.Application.ScreenUpdating = false;

                    // import the data
                    Excel.Worksheet temp = importFile(fileList.GetValue(index).ToString(), (index + 1).ToString(), type);

                    // copy the reel data to the corresponding match and pay sheets
                    updateMatchLinks(temp, fileList.GetValue(index).ToString());
                    updatePayLinks(temp, fileList.GetValue(index).ToString());
                    // let the user see that we're working
                    Globals.Program.Application.ScreenUpdating = true;
                    currentReelSet++;
                }
            }
            if (type == ReelDataType.BALLY)
            {
                m_gamePays = new BallyGamePays();
                m_gameSet = new BallyReelGame();
                importBallyFile(fileList.GetValue(0).ToString(), "1");
            }
        }
예제 #38
0
        void Application_WindowActivate(Excel.Workbook Wb, Excel.Window Wn)
        {
            Excel.Worksheet activeSheet = (Excel.Worksheet)Application.ActiveSheet;

            RepairDocument(activeSheet);
        }
예제 #39
0
 public CalcImport()
 {
     excelWin = Globals.Program.Application.ActiveWindow;
 }