Ewa.SheetCollection.getItem(index)

**適用対象:**apps for SharePoint | Excel Services | SharePoint Server 2013

この記事の内容
戻り値
注釈

対象

nth Ewa.Sheetを取得します。

var value = Ewa.SheetCollection.getItem(index);

パラメーター

index

整数値をグラフ シートのシートの順序を指定します。

戻り値

[Type]: Ewa.Sheet

注釈

Ewa.SheetCollection.getItemメソッドは、シートのインデックスの値を使用して、指定したシートを返します。インデックスが始まるです。n番目のシートが存在しない場合は、 nullを返します。

次の例では、ページにボタンを追加する方法について説明し、 Ewa.Sheet.activateAsyncメソッドを使用して、ブック内の次のシートをアクティブにして、ブラウザーのステータス バーで、シート名を表示する] ボタンのonClickイベントにコードを追加します。ボタンをクリックでは、次のボタンをクリックした時点でコレクション内の最初のシートにあるシートの先頭をアクティブ化の最後のシートが有効になるまで、シートのコレクション内の次のシートがアクティブにします。コードの例をExcel Web Access Web パーツでSharePoint Server 2013で作業していることを前提としています。

<script type="text/javascript">
     
var ewa = null;
var sheetCount = 1;
     
// Add event handler for onload event.
if (window.attachEvent) 
{ 
    window.attachEvent("onload", ewaOnPageLoad);    
} 
else 
{ 
    window.addEventListener("DOMContentLoaded", ewaOnPageLoad, false); 
}

// Add event handler for applicationReady event.
function ewaOnPageLoad() 
{         
    Ewa.EwaControl.add_applicationReady(onApplicationReady); 
} 

function onApplicationReady()
{            
    // Get a reference to the Excel Services Web Part.
    ewa = Ewa.EwaControl.getInstances().getItem(0);                                   
}              
        
function activateSheetButton()
{    
    // Get a reference to the workbook.
    var wkBook = ewa.getActiveWorkbook();    
        
    
    // Get the collection of sheets in the workbook.
    var sheets = wkBook.getSheets();
    
    // Get the next sheet.
        var sheet = sheets.getItem(sheetCount);
                
    sheetCount++;
    
    // If at the end of the sheets collection, start over.
    if (sheetCount >= sheets.getCount())
    {
        sheetCount = 0;
    } 
           
    // Activate the specified sheet.
    // Pass in sheet as user context.
    sheet.activateAsync(activateSheetCallBack, sheet);    
}

      
function activateSheetCallBack(asyncResult)
{  
    // Get the activated sheet from user context.
    var activatedSheet = asyncResult.getUserContext();
    
    // Display name of activated sheet in browser status bar.
    window.status = "Sheet " + activatedSheet.getName() + " was activated.";    
}

</script>
<input type="button" id="ActivateSheet" value="Activate Sheet" onclick="activateSheetButton()" />

対象

Ewa.SheetCollection オブジェクト

関連項目

概念

Ewa.SheetCollection 方法

Ewa 名前空間