本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}