Export (0) Print
Expand All
Expand Minimize

ChartSheetBase.Previous Property

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Gets a Microsoft.Office.Interop.Excel.Worksheet object that represents the previous sheet.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

public Object Previous { get; }

Property Value

Type: System.Object
A Microsoft.Office.Interop.Excel.Worksheet object that represents the previous sheet.

The following code example uses the Next and Previous properties to display the names of the next and previous sheets for the current Microsoft.Office.Tools.Excel.ChartSheetBase.

private void DisplayNextAndPrevious()
{
    Globals.Sheet1.Range["A1", "A5"].Value2 = 22;
    Globals.Sheet1.Range["B1", "B5"].Value2 = 55;

    this.SetSourceData(Globals.Sheet1.Range["A1", "B5"],
        Excel.XlRowCol.xlColumns);
    this.ChartType = Excel.XlChartType.xl3DColumn;

    Excel.Worksheet nextSheet = (Excel.Worksheet)this.Next;
    Excel.Worksheet previousSheet = 
        (Excel.Worksheet)this.Previous;

    if (nextSheet != null)
    {
        MessageBox.Show("The next sheet is: " + 
            nextSheet.Name);
    }
    else
    {
        MessageBox.Show("This sheet is the last sheet.");
    }

    if (previousSheet != null)
    {
        MessageBox.Show("The previous sheet is: " + 
            previousSheet.Name);
    }
    else
    {
        MessageBox.Show("This sheet is the first sheet.");
    }
}

Show:
© 2014 Microsoft