/*
* Demonstrate DisplayReference and DisplayReferenceName usage.
*/
private void radioButton_CheckedChanged(object sender, EventArgs e)
{
if (radioButtonWorkbook.Checked)
{
// Change the display reference to a workbook.
workbookView.DisplayReference = "Book2";
workbookView.DisplayReferenceName = null;
}
else if (radioButtonWorksheet.Checked)
{
// Change the display reference to a worksheet and name it.
workbookView.DisplayReference = "[Book1]Sheet1!A:IV";
workbookView.DisplayReferenceName = "\"My Worksheet\"";
}
else if (radioButtonRange.Checked)
{
// Change the display reference to a range and name it.
workbookView.DisplayReference = "[Book3]Sheet2!A1:C3";
workbookView.DisplayReferenceName = "\"My Range\"";
}
else if (radioButtonDefinedName.Checked)
{
// Change the display reference to a defined name and name it.
workbookView.DisplayReference = "Book2!MyName";
workbookView.DisplayReferenceName = "\"My Defined Name\"";
}
else if (radioButtonMultipleRanges.Checked)
{
// Change the display reference to multiple ranges and name them.
workbookView.DisplayReference = "[Book1]Sheet1!A1:C3,[Book1]Sheet1!4:6,[Book1]Sheet1!D:F";
workbookView.DisplayReferenceName = "\"My Range1\",\"My Range2\",\"My Range3\"";
}
}