Ewa.SheetCollection.getCount()
**適用対象:**apps for SharePoint | Excel Services | SharePoint Server 2013
この記事の内容
戻り値
注釈
例
対象
ブックのシートの数を取得します。
var value = Ewa.SheetCollection.getCount();
戻り値
[Type]: integer
注釈
Ewa.SheetCollection.getCount方法では、ブックのシート数を返します。シートの数を表すには、ワークシートやグラフ シートが含まれています。
例
次の例では、ページにボタンを追加する方法について説明し、し、警告メッセージでのブックのシートの総数を表示する] ボタンのonClickイベントにイベント ハンドラーを追加します。コードの例をExcel Web Access Web パーツでSharePoint Server 2013で作業していることを前提としています。
<script type="text/javascript">
var ewa = null;
// 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);
}
// Add event handler for button onClick event.
function getSheetCountButton()
{
// Get the Sheets collection.
var sheets = ewa.getActiveWorkbook().getSheets();
// Display count of sheets in workbook.
alert("There are " + sheets.getCount() + " sheets.");
}
</script>
<input type="button" id="GetSheetCount" value="Get Sheet Count" onclick="getSheetCountButton()" />