protected override void HandleWriteStarted()
        {
            // There are problems with exporting to excel on non-English machines
            // See: http://www.made4dotnet.com/Default.aspx?tabid=141&aid=15
            iOriginalCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
            ChangeToEnglishCulture();

            iExcelApp = new Microsoft.Office.Interop.Excel.Application();
            iExcelApp.DisplayAlerts = false;

            Workbooks workbooks = iExcelApp.Workbooks;

            workbooks.Add(XlWBATemplate.xlWBATWorksheet);
            iWorkbook = workbooks.get_Item(workbooks.Count);

            // Create summary sheet
            Sheets sheets = iWorkbook.Worksheets;

            iSummary = (Worksheet)sheets.get_Item(1);
            CreateSummary(iSummary);

            // Create pages
            iPages.Add(new Pages.PageUnchanged(iEngine.ResultsUnchanged, iWorkbook));
            iPages.Add(new Pages.PageUnique(iEngine.Reconstructor2, iEngine.ResultsUniqueInHeap2, iWorkbook, "Unique in Heap 2", 2, 1));
            iPages.Add(new Pages.PageUnique(iEngine.Reconstructor1, iEngine.ResultsUniqueInHeap1, iWorkbook, "Unique in Heap 1", 1, 2));
            iPages.Add(new Pages.PageSimpleListing(iEngine.ResultsUnchangedLengthButDifferentContents, iWorkbook, "Same length, different contents"));
            iPages.Add(new Pages.PageSimpleListing(iEngine.ResultsChanged, iWorkbook, "Changed", false));
        }
Ejemplo n.º 2
0
        private void CreateNewWorkbook(Worksheet excelworksheet, string unic_value,
                                       Sheets excelallsheets, Workbooks excelappallworkbooks, string CurDir, int iterationNumber)
        {
            excelworksheet.get_Range("$A$1:$R$5781", Type.Missing)
            .AutoFilter(1, unic_value);

            var selectFilteredCells = excelworksheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeVisible);

            selectFilteredCells.Copy();
            var newexcelsheet = excelallsheets.Add().Paste();

            excelworksheet.Visible = Excel.XlSheetVisibility.xlSheetVisible;
            excelworksheet         = (Excel.Worksheet)excelallsheets.get_Item(1);
            excelworksheet.Move();
            var misValue = Type.Missing;

            var newexcelbook = excelappallworkbooks.get_Item(2);

            newexcelbook.SaveAs(CurDir + @"\" + iterationNumber + @".xlsx", Type.Missing, Type.Missing, Type.Missing
                                , Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, XlSaveConflictResolution.xlLocalSessionChanges
                                , Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            newexcelbook.Close();
        }
Ejemplo n.º 3
0
        private void axWebBrowser2_NavigateComplete2(object sender, AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event e)
        {
            ///   return;

            object o = e.pDisp;

            oWebBrowser = e.pDisp;
            try
            {
                Object            oDocument    = o.GetType().InvokeMember("Document", BindingFlags.GetProperty, null, o, null);
                Object            oApplication = o.GetType().InvokeMember("Application", BindingFlags.GetProperty, null, oDocument, null);
                Excel.Application eApp         = (Excel.Application)oApplication;
                eApp.UserControl = true;
                //Inputexcel(eApp);
                //textexcel();


                #region 方法2
                //Object refmissing = System.Reflection.Missing.Value;
                //object[] args = new object[4];
                //args[0] = SHDocVw.OLECMDID.OLECMDID_HIDETOOLBARS;
                //args[1] = SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER;
                //args[2] = refmissing;
                //args[3] = refmissing;

                //object axWebBrowser = this.webBrowser1.ActiveXInstance;

                //axWebBrowser.GetType().InvokeMember("ExecWB",
                //    BindingFlags.InvokeMethod, null, axWebBrowser, args);


                //object Application = axWebBrowser.GetType().InvokeMember("Document",
                //    BindingFlags.GetProperty, null, axWebBrowser, null);

                //Excel.Workbook wbb = (Excel.Workbook)oApplication;
                //Excel.ApplicationClass excel = wbb.Application as Excel.ApplicationClass;
                //Excel.Workbook wb = excel.Workbooks[1];
                //Excel.Worksheet ws = wb.Worksheets[1] as Excel.Worksheet;
                //ws.Cells.Font.Name = "Verdana";
                //ws.Cells.Font.Size = 14;
                //ws.Cells.Font.Bold = true;
                //Excel.Range range = ws.Cells;

                //Excel.Range oCell = range[10, 10] as Excel.Range;
                //oCell.Value2 = "你好";
                #endregion


                #region inster tx
                //object objBooks = eApp.GetType().InvokeMember("Workbooks", BindingFlags.GetProperty, null, eApp, null);

                ////添加一个新的Workbook
                //object objBook = objBooks.GetType().InvokeMember("Add", BindingFlags.InvokeMethod, null, objBooks, null);
                ////获取Sheet集
                //object objSheets = objBook.GetType().InvokeMember("Worksheets", BindingFlags.GetProperty, null, objBook, null);

                ////获取第一个Sheet对象
                //object[] Parameters = new Object[1] { 1 };
                //object objSheet = objSheets.GetType().InvokeMember("Item", BindingFlags.GetProperty, null, objSheets, Parameters);

                //Parameters = new Object[2] { 1, 1 + 1 };
                //object objCells = objSheet.GetType().InvokeMember("Cells", BindingFlags.GetProperty, null, objSheet, Parameters);
                ////向指定单元格填写内容值
                //Parameters = new Object[1] { "name" };
                //objCells.GetType().InvokeMember("Value", BindingFlags.SetProperty, null, objCells, Parameters);

                #endregion

                #region 一、首先简要回顾一下如何操作Excel表
                Workbooks workbooks          = eApp.Workbooks;
                Excel.ApplicationClass excel = workbooks.Application as Excel.ApplicationClass;
                Microsoft.Office.Interop.Excel.Worksheet WS = (Microsoft.Office.Interop.Excel.Worksheet)workbooks.get_Item(1);
                Excel.Workbook wb = excel.Workbooks[1];
                //_Workbook workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet);
                int       c        = workbooks.Count;
                _Workbook workbook = workbooks.Add(ZFCEPath);
                Sheets    sheets   = workbook.Worksheets;

                _Worksheet worksheet = (_Worksheet)sheets.get_Item(1);
                Range      range1    = worksheet.get_Range("A1", Missing.Value);
                const int  nCells    = 2345;
                range1.Value2 = nCells;

                #endregion


                ExcelExit();
            }
            catch (Exception ex)
            {
                ExcelExit();

                throw;
            }
        }