OneNote.Table class
OneNote ページのテーブルを表します。
- Extends
注釈
プロパティ
border |
枠線を表示するかどうかを取得または設定します。 表示する場合は true、非表示の場合は false。 |
column |
表の列数を取得します。 |
context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
id | テーブルの ID を取得します。 読み取り専用です。 |
paragraph | Table オブジェクトを含む Paragraph オブジェクトを取得します。 読み取り専用です。 |
row |
表の行数を取得します。 |
rows | すべてのテーブルの行を取得します。 読み取り専用です。 |
メソッド
append |
テーブルの末尾に列を追加します。 値が指定されている場合、新しい列に設定されます。 指定されてない場合、列は空です。 |
append |
テーブルの末尾に行を追加します。 値が指定されている場合、新しい行に設定されます。 指定されてない場合、行は空です。 |
clear() | テーブルの内容をクリアします。 |
get |
指定された行と列のテーブル セルを取得します。 |
insert |
テーブル内の指定したインデックスに列を挿入します。 値が指定されている場合、新しい列に設定されます。 指定されてない場合、列は空です。 |
insert |
テーブル内の指定したインデックスに行を挿入します。 値が指定されている場合、新しい行に設定されます。 指定されてない場合、行は空です。 |
load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
set(properties, options) | オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクトまたは同じ型の別の API オブジェクトを渡すことができます。 |
set(properties) | 既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。 |
set |
テーブルのすべてのセルの網かけの色を設定します。 セルに設定する色コード。 |
toJSON() | API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript |
track() | ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは の短縮形です |
untrack() | 前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは の |
プロパティの詳細
borderVisible
枠線を表示するかどうかを取得または設定します。 表示する場合は true、非表示の場合は false。
borderVisible: boolean;
プロパティ値
boolean
注釈
columnCount
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
id
paragraph
Table オブジェクトを含む Paragraph オブジェクトを取得します。 読み取り専用です。
readonly paragraph: OneNote.Paragraph;
プロパティ値
注釈
rowCount
rows
すべてのテーブルの行を取得します。 読み取り専用です。
readonly rows: OneNote.TableRowCollection;
プロパティ値
注釈
メソッドの詳細
appendColumn(values)
テーブルの末尾に列を追加します。 値が指定されている場合、新しい列に設定されます。 指定されてない場合、列は空です。
appendColumn(values?: string[]): void;
パラメーター
- values
-
string[]
オプション。 配列として指定された、新しい列に挿入する文字列。 テーブルの行数よりも多い値は指定できません。
戻り値
void
注釈
例
await OneNote.run(async (context) => {
const app = context.application;
const outline = app.getActiveOutline();
// Queue a command to load outline.paragraphs and their types.
context.load(outline, "paragraphs, paragraphs/type");
// Run the queued commands, and return a promise to indicate task completion.
await context.sync();
const paragraphs = outline.paragraphs;
// For each table, append a column.
for (let i = 0; i < paragraphs.items.length; i++) {
const paragraph = paragraphs.items[i];
if (paragraph.type == "Table") {
const table = paragraph.table;
table.appendColumn(["cell0", "cell1"]);
}
}
await context.sync();
});
appendRow(values)
テーブルの末尾に行を追加します。 値が指定されている場合、新しい行に設定されます。 指定されてない場合、行は空です。
appendRow(values?: string[]): OneNote.TableRow;
パラメーター
- values
-
string[]
オプション。 配列として指定された、新しい行に挿入する文字列。 テーブルの列数よりも多い値は指定できません。
戻り値
注釈
例
await OneNote.run(async (context) => {
const app = context.application;
const outline = app.getActiveOutline();
// Queue a command to load outline.paragraphs and their types.
context.load(outline, "paragraphs, paragraphs/type");
// Run the queued commands, and return a promise to indicate task completion.
await context.sync();
const paragraphs = outline.paragraphs;
// For each table, append a column.
for (let i = 0; i < paragraphs.items.length; i++) {
const paragraph = paragraphs.items[i];
if (paragraph.type == "Table") {
const table = paragraph.table;
const row = table.appendRow(["cell0", "cell1"]);
}
}
await context.sync();
});
clear()
getCell(rowIndex, cellIndex)
指定された行と列のテーブル セルを取得します。
getCell(rowIndex: number, cellIndex: number): OneNote.TableCell;
パラメーター
- rowIndex
-
number
行のインデックスです。
- cellIndex
-
number
行のセルのインデックス。
戻り値
注釈
例
await OneNote.run(async (context) => {
const app = context.application;
const outline = app.getActiveOutline();
// Queue a command to load outline.paragraphs and their types.
context.load(outline, "paragraphs, paragraphs/type");
// Run the queued commands, and return a promise to indicate task completion.
await context.sync();
const paragraphs = outline.paragraphs;
// For each table, get a cell in the second row and third column.
for (let i = 0; i < paragraphs.items.length; i++) {
const paragraph = paragraphs.items[i];
if (paragraph.type == "Table") {
const table = paragraph.table;
const cell = table.getCell(2 /*Row Index*/, 3 /*Column Index*/);
}
}
await context.sync();
});
insertColumn(index, values)
テーブル内の指定したインデックスに列を挿入します。 値が指定されている場合、新しい列に設定されます。 指定されてない場合、列は空です。
insertColumn(index: number, values?: string[]): void;
パラメーター
- index
-
number
テーブルに列を挿入する位置のインデックス。
- values
-
string[]
オプション。 配列として指定された、新しい列に挿入する文字列。 テーブルの行数よりも多い値は指定できません。
戻り値
void
注釈
例
await OneNote.run(async (context) => {
const app = context.application;
const outline = app.getActiveOutline();
// Queue a command to load outline.paragraphs and their types.
context.load(outline, "paragraphs, paragraphs/type");
// Run the queued commands, and return a promise to indicate task completion.
await context.sync();
const paragraphs = outline.paragraphs;
// For each table, insert a column at index two.
for (let i = 0; i < paragraphs.items.length; i++) {
const paragraph = paragraphs.items[i];
if (paragraph.type == "Table") {
const table = paragraph.table;
table.insertColumn(2, ["cell0", "cell1"]);
}
}
await context.sync();
});
insertRow(index, values)
テーブル内の指定したインデックスに行を挿入します。 値が指定されている場合、新しい行に設定されます。 指定されてない場合、行は空です。
insertRow(index: number, values?: string[]): OneNote.TableRow;
パラメーター
- index
-
number
テーブルに行を挿入する位置のインデックス。
- values
-
string[]
オプション。 配列として指定された、新しい行に挿入する文字列。 テーブルの列数よりも多い値は指定できません。
戻り値
注釈
例
await OneNote.run(async (context) => {
const app = context.application;
const outline = app.getActiveOutline();
// Queue a command to load outline.paragraphs and their types.
context.load(outline, "paragraphs, paragraphs/type");
// Run the queued commands, and return a promise to indicate task completion.
await context.sync()
const paragraphs = outline.paragraphs;
// For each table, insert a row at index two.
for (let i = 0; i < paragraphs.items.length; i++) {
const paragraph = paragraphs.items[i];
if (paragraph.type == "Table") {
const table = paragraph.table;
const row = table.insertRow(2, ["cell0", "cell1"]);
}
}
await context.sync();
});
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync()
を呼び出す必要があります。
load(options?: OneNote.Interfaces.TableLoadOptions): OneNote.Table;
パラメーター
読み込むオブジェクトのプロパティのオプションを提供します。
戻り値
load(propertyNames)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync()
を呼び出す必要があります。
load(propertyNames?: string | string[]): OneNote.Table;
パラメーター
- propertyNames
-
string | string[]
読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。
戻り値
例
await OneNote.run(async (context) => {
const app = context.application;
const outline = app.getActiveOutline();
// Queue a command to load outline.paragraphs and their types.
context.load(outline, "paragraphs/type");
// Run the queued commands, and return a promise to indicate task completion.
await context.sync();
const paragraphs = outline.paragraphs;
// For each table, log properties.
for (let i = 0; i < paragraphs.items.length; i++) {
const paragraph = paragraphs.items[i];
if (paragraph.type == "Table") {
const table = paragraph.table;
context.load(table);
await context.sync();
console.log("Table Id: " + table.id);
console.log("Row Count: " + table.rowCount);
console.log("Column Count: " + table.columnCount);
await context.sync();
}
}
});
load(propertyNamesAndPaths)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync()
を呼び出す必要があります。
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): OneNote.Table;
パラメーター
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select
は、読み込むプロパティを指定するコンマ区切り文字列で propertyNamesAndPaths.expand
、読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。
戻り値
set(properties, options)
オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクトまたは同じ型の別の API オブジェクトを渡すことができます。
set(properties: Interfaces.TableUpdateData, options?: OfficeExtension.UpdateOptions): void;
パラメーター
- properties
- OneNote.Interfaces.TableUpdateData
メソッドが呼び出されるオブジェクトのプロパティに等形的に構造化されたプロパティを持つ JavaScript オブジェクト。
- options
- OfficeExtension.UpdateOptions
properties オブジェクトが読み取り専用プロパティを設定しようとした場合にエラーを抑制するオプションを提供します。
戻り値
void
set(properties)
既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。
set(properties: OneNote.Table): void;
パラメーター
- properties
- OneNote.Table
戻り値
void
setShadingColor(colorCode)
テーブルのすべてのセルの網かけの色を設定します。 セルに設定する色コード。
setShadingColor(colorCode: string): void;
パラメーター
- colorCode
-
string
戻り値
void
注釈
toJSON()
API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript toJSON()
メソッドを JSON.stringify()
オーバーライドします。 (JSON.stringify
さらに、渡される オブジェクトの メソッドを呼び出 toJSON
します)。元の OneNote.Table オブジェクトは API オブジェクトですが、メソッドは、元の toJSON
オブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト (として OneNote.Interfaces.TableData
型指定) を返します。
toJSON(): OneNote.Interfaces.TableData;
戻り値
track()
ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは の短縮形です context.trackedObjects.add(thisObject)
。 このオブジェクトを呼び出しで .sync
使用し、".run" バッチのシーケンシャル実行の外部で使用していて、プロパティを設定するとき、またはオブジェクトのメソッドを呼び出すときに "InvalidObjectPath" エラーが発生する場合は、オブジェクトが最初に作成されたときに、追跡対象のオブジェクト コレクションにオブジェクトを追加する必要があります。
track(): OneNote.Table;
戻り値
untrack()
前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは の context.trackedObjects.remove(thisObject)
短縮形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ解放が有効になる前に を呼び出す context.sync()
必要があります。
untrack(): OneNote.Table;
戻り値
Office Add-ins
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示