當前位置: 首頁>>代碼示例>>C#>>正文


C# HSSFWorkbook.SetSelectedTab方法代碼示例

本文整理匯總了C#中NPOI.HSSF.UserModel.HSSFWorkbook.SetSelectedTab方法的典型用法代碼示例。如果您正苦於以下問題:C# HSSFWorkbook.SetSelectedTab方法的具體用法?C# HSSFWorkbook.SetSelectedTab怎麽用?C# HSSFWorkbook.SetSelectedTab使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NPOI.HSSF.UserModel.HSSFWorkbook的用法示例。


在下文中一共展示了HSSFWorkbook.SetSelectedTab方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestSelectedSheetshort

        public void TestSelectedSheetshort()
        {
            HSSFWorkbook wb = new HSSFWorkbook();
            HSSFSheet sheet1 = (HSSFSheet)wb.CreateSheet("Sheet1");
            HSSFSheet sheet2 = (HSSFSheet)wb.CreateSheet("Sheet2");
            HSSFSheet sheet3 = (HSSFSheet)wb.CreateSheet("Sheet3");
            HSSFSheet sheet4 = (HSSFSheet)wb.CreateSheet("Sheet4");

            ConfirmActiveSelected(sheet1, true);
            ConfirmActiveSelected(sheet2, false);
            ConfirmActiveSelected(sheet3, false);
            ConfirmActiveSelected(sheet4, false);

            wb.SetSelectedTab((short)1);

            // see Javadoc, in this case selected means "active"
            Assert.AreEqual(wb.ActiveSheetIndex, (short)wb.ActiveSheetIndex);

            // Demonstrate bug 44525:
            // Well... not quite, since isActive + isSelected were also Added in the same bug fix
            if (sheet1.IsSelected)
            {
                //throw new AssertionFailedError("Identified bug 44523 a");
                Assert.Fail("Identified bug 44523 a");
            }
            wb.SetActiveSheet(1);
            if (sheet1.IsActive)
            {
                //throw new AssertionFailedError("Identified bug 44523 b");
                Assert.Fail("Identified bug 44523 b");
            }

            ConfirmActiveSelected(sheet1, false);
            ConfirmActiveSelected(sheet2, true);
            ConfirmActiveSelected(sheet3, false);
            ConfirmActiveSelected(sheet4, false);

            Assert.AreEqual(0, wb.FirstVisibleTab);
            //wb.DisplayedTab=((short)2);
            //Assert.AreEqual(2, wb.FirstVisibleTab);
            //Assert.AreEqual(2, wb.DisplayedTab);
        }
開發者ID:mdjasim,項目名稱:npoi,代碼行數:42,代碼來源:TestHSSFWorkbook.cs

示例2: TestSelectedSheet_bug44523

        public void TestSelectedSheet_bug44523()
        {
            HSSFWorkbook wb = new HSSFWorkbook();
            NPOI.SS.UserModel.ISheet sheet1 = wb.CreateSheet("Sheet1");
            NPOI.SS.UserModel.ISheet sheet2 = wb.CreateSheet("Sheet2");
            NPOI.SS.UserModel.ISheet sheet3 = wb.CreateSheet("Sheet3");
            NPOI.SS.UserModel.ISheet sheet4 = wb.CreateSheet("Sheet4");

            ConfirmActiveSelected(sheet1, true);
            ConfirmActiveSelected(sheet2, false);
            ConfirmActiveSelected(sheet3, false);
            ConfirmActiveSelected(sheet4, false);

            wb.SetSelectedTab(1);
            // see Javadoc, in this case selected means "active"
            Assert.AreEqual(wb.ActiveSheetIndex, (short)wb.ActiveSheetIndex);


            // Demonstrate bug 44525:
            // Well... not quite, since isActive + isSelected were also Added in the same bug fix
            if (sheet1.IsSelected)
            {
                throw new AssertionException("Identified bug 44523 a");
            }
            wb.SetActiveSheet(1);
            if (sheet1.IsActive)
            {
                throw new AssertionException("Identified bug 44523 b");
            }

            ConfirmActiveSelected(sheet1, false);
            ConfirmActiveSelected(sheet2, true);
            ConfirmActiveSelected(sheet3, false);
            ConfirmActiveSelected(sheet4, false);
        }
開發者ID:mdjasim,項目名稱:npoi,代碼行數:35,代碼來源:TestHSSFWorkbook.cs

示例3: TestActiveSheetAfterDelete_bug40414

        public void TestActiveSheetAfterDelete_bug40414()
        {
            HSSFWorkbook wb = new HSSFWorkbook();
            NPOI.SS.UserModel.ISheet sheet0 = wb.CreateSheet("Sheet0");
            NPOI.SS.UserModel.ISheet sheet1 = wb.CreateSheet("Sheet1");
            NPOI.SS.UserModel.ISheet sheet2 = wb.CreateSheet("Sheet2");
            NPOI.SS.UserModel.ISheet sheet3 = wb.CreateSheet("Sheet3");
            NPOI.SS.UserModel.ISheet sheet4 = wb.CreateSheet("Sheet4");

            // Confirm default activation/selection
            ConfirmActiveSelected(sheet0, true);
            ConfirmActiveSelected(sheet1, false);
            ConfirmActiveSelected(sheet2, false);
            ConfirmActiveSelected(sheet3, false);
            ConfirmActiveSelected(sheet4, false);

            wb.SetActiveSheet(3);
            wb.SetSelectedTab(3);

            ConfirmActiveSelected(sheet0, false);
            ConfirmActiveSelected(sheet1, false);
            ConfirmActiveSelected(sheet2, false);
            ConfirmActiveSelected(sheet3, true);
            ConfirmActiveSelected(sheet4, false);

            wb.RemoveSheetAt(3);
            // after removing the only active/selected sheet, another should be active/selected in its place
            if (!sheet4.IsSelected)
            {
                throw new AssertionException("identified bug 40414 a");
            }
            if (!sheet4.IsActive)
            {
                throw new AssertionException("identified bug 40414 b");
            }

            ConfirmActiveSelected(sheet0, false);
            ConfirmActiveSelected(sheet1, false);
            ConfirmActiveSelected(sheet2, false);
            ConfirmActiveSelected(sheet4, true);

            sheet3 = sheet4; // re-align local vars in this Test case

            // Some more cases of removing sheets

            // Starting with a multiple selection, and different active sheet
            wb.SetSelectedTabs(new int[] { 1, 3, });
            wb.SetActiveSheet(2);
            ConfirmActiveSelected(sheet0, false, false);
            ConfirmActiveSelected(sheet1, false, true);
            ConfirmActiveSelected(sheet2, true, false);
            ConfirmActiveSelected(sheet3, false, true);

            // removing a sheet that is not active, and not the only selected sheet
            wb.RemoveSheetAt(3);
            ConfirmActiveSelected(sheet0, false, false);
            ConfirmActiveSelected(sheet1, false, true);
            ConfirmActiveSelected(sheet2, true, false);

            // removing the only selected sheet
            wb.RemoveSheetAt(1);
            ConfirmActiveSelected(sheet0, false, false);
            ConfirmActiveSelected(sheet2, true, true);

            // The last remaining sheet should always be active+selected
            wb.RemoveSheetAt(1);
            ConfirmActiveSelected(sheet0, true, true);
        }
開發者ID:mdjasim,項目名稱:npoi,代碼行數:68,代碼來源:TestHSSFWorkbook.cs

示例4: TestSheetSelection

 public new void TestSheetSelection()
 {
     HSSFWorkbook b = new HSSFWorkbook();
     b.CreateSheet("Sheet One");
     b.CreateSheet("Sheet Two");
     b.SetActiveSheet(1);
     b.SetSelectedTab(1);
     b.FirstVisibleTab = (1);
     Assert.AreEqual(1, b.ActiveSheetIndex);
     Assert.AreEqual(1, b.FirstVisibleTab);
 }
開發者ID:mdjasim,項目名稱:npoi,代碼行數:11,代碼來源:TestHSSFWorkbook.cs


注:本文中的NPOI.HSSF.UserModel.HSSFWorkbook.SetSelectedTab方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。