GridWebの行と列との作業
行と列の挿入
このトピックでは、Aspose.Cells.GridWeb APIを使用してワークシートに新しい行や列を挿入する方法について説明します。行または列はワークシートの任意の位置に挿入できます。
行の挿入
ワークシートの任意の位置に行を挿入するには:
- Aspose.Cells.GridWeb コントロールを Web フォームまたはページに追加します。
- 行を追加するワークシートにアクセスします。
- 行が挿入される行インデックスを指定して行を挿入します。
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Accessing the reference of the worksheet that is currently active | |
GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
//Inserting a new row to the worksheet before 2nd row | |
sheet.getCells().insertRow(1); | |
列の挿入
ワークシートの任意の位置に列を挿入するには:
- Aspose.Cells.GridWeb コントロールを Web フォームまたはページに追加します。
- 列を追加するワークシートにアクセスします。
- 列が挿入される列インデックスを指定して列を挿入します。
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Accessing the reference of the worksheet that is currently active | |
GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
//Inserting a new column to the worksheet before column "B" | |
sheet.getCells().insertColumn(1); | |
行と列の削除
このトピックでは、Aspose.Cells.GridWeb API を使用してワークシートから行や列を削除する方法について説明します。この機能のおかげで、開発者は実行時に行や列を削除できます。
行の削除
ワークシートから行を削除するには:
- Aspose.Cells.GridWeb コントロールを Web フォームまたはページに追加します。
- 行を削除するワークシートにアクセスします。
- 行のインデックスを指定してワークシートから行を削除します。
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Accessing the reference of the worksheet that is currently active | |
GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
//Deleting 2nd row from the worksheet | |
sheet.getCells().deleteRow(1); | |
列の削除
ワークシートから列を削除するには:
- Aspose.Cells.GridWeb コントロールを Web フォームまたはページに追加します。
- 列を削除したいワークシートにアクセスします。
- 列のインデックスを指定してワークシートから列を削除します。
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Accessing the reference of the worksheet that is currently active | |
GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
//Deleting 2nd column from the worksheet | |
sheet.getCells().deleteColumn(1); | |
行の高さと列の幅の設定
セルの値がセルの幅を超える場合や複数行に渡る場合があります。そのような値は、行と列の高さと幅を変更しない限り、ユーザーに完全に表示されません。Aspose.Cells.GridWeb は行の高さと列の幅の設定を完全にサポートしています。このトピックでは、これらの機能について、例を挙げて詳しく説明します。
行の高さと列の幅の設定
行の高さの設定
行の高さを設定するには:
- Web フォーム/ページに Aspose.Cells.GridWeb コントロールを追加します。
- ワークシートの GridCells コレクションにアクセスします。
- 指定された行内のすべてのセルの高さを設定します。
出力: 第1行の高さが50ポイントに設定されました
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Accessing the cells collection of the worksheet that is currently active | |
GridCells cells = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()).getCells(); | |
//Setting the height of 1st row to 50 points | |
cells.setRowHeight(0, 50); | |
列の幅の設定
列の幅を設定するには:
- Web フォーム/ページに Aspose.Cells.GridWeb コントロールを追加します。
- ワークシートの GridCells コレクションにアクセスします。
- 指定された列内のすべてのセルの幅を設定します。
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Accessing the cells collection of the worksheet that is currently active | |
GridCells cells = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()).getCells(); | |
//Setting the width of 1st column to 150 points | |
cells.setColumnWidth(0, 150); | |
行と列ヘッダーのカスタマイズ
Microsoft Excel のように、Aspose.Cells.GridWeb は行(1、2、3 などの数字)と列(A、B、C などのアルファベット)に標準のヘッダーまたは見出しを使用します。Aspose.Cells.GridWeb は見出しをカスタマイズすることも可能にします。このトピックでは、Aspose.Cells.GridWeb API を使用して実行時に行と列のヘッダーをカスタマイズする方法について説明します。
行ヘッダーのカスタマイズ
行のヘッダーやキャプションをカスタマイズするには:
- Web フォーム/ページに Aspose.Cells.GridWeb コントロールを追加します。
- GridWorksheetCollection内のワークシートにアクセスします。
- 指定した行のキャプションを設定します。
行1および2のヘッダーがカスタマイズされました
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Accessing the worksheet that is currently active | |
GridWorksheet worksheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
//Setting the header of 1st row to "ID" | |
worksheet.setRowCaption(1, "ID"); | |
//Setting the header of 2nd row to "Name" | |
worksheet.setRowCaption(2, "Name"); | |
列ヘッダーのカスタマイズ
列のヘッダーやキャプションをカスタマイズするには:
- Web フォーム/ページに Aspose.Cells.GridWeb コントロールを追加します。
- GridWorksheetCollection内のワークシートにアクセスします。
- 指定した列のキャプションを設定します。
列1および2のヘッダーがカスタマイズされました
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Accessing the worksheet that is currently active | |
GridWorksheet worksheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
//Setting the header of 1st column to "ID" | |
worksheet.SetColumnCaption(0, "ID"); | |
//Setting the header of 2nd column to "Name" | |
worksheet.SetColumnCaption(1, "Name"); | |
行と列の固定、解除
このトピックでは、行や列を凍結および解凍する方法について説明します。列や行を凍結すると、ユーザーはワークシートの他の部分にスクロールする際にも、列の見出しや行のタイトルを表示した状態で保持することができます。この機能は、大量のデータを含むワークシートで作業する際に非常に役立ちます。ユーザーがスクロールする際にも、見出しはそのままでデータのみがスクロールし、データを見やすくします。凍結の機能は、Internet Explorer 6.0 以降でのみサポートされています。
行と列の凍結
特定の行数と列数を凍結するには:
- Web フォーム/ページに Aspose.Cells.GridWeb コントロールを追加します。
- ワークシートにアクセスします。
- 行数と列数を凍結します。
凍結状態の行と列
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Accessing the reference of the worksheet that is currently active | |
GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
//Freezing 4th row and 3rd column | |
sheet.freezePanes(3, 2, 3, 2); | |
行と列の凍結を解除
行と列を解凍するには:
- Web フォーム/ページに Aspose.Cells.GridWeb コントロールを追加します。
- ワークシートにアクセスします。
- 行と列を解凍します。
解凍後のワークシート
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Accessing the reference of the worksheet that is currently active | |
GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
//Unfreezing rows and columns | |
sheet.unFreezePanes(); | |
行と列の保護
このトピックでは、エンドユーザーによる行と列内のセルのいかなるアクションからも保護するためのいくつかの技術について説明します。開発者は、行と列内のセルを読み取り専用にすること、または GridWeb のコンテキストメニューオプションを制限することで、この保護を実装することができます。
コンテキストメニューオプションの制限
GridWebは、コントロール上で操作を実行するためにエンドユーザーが使用できるコンテキストメニューを提供します。このメニューにはセル、行、列を操作するための多くのオプションがあります。
完全なコンテキストオプション
コンテキストメニューで利用可能なオプションを制限することで、行や列に対する任意のクライアントサイド操作を制限することが可能です。これは、GridWebコントロールのEnableClientColumnOperationsおよびEnableClientRowOperations属性をfalseに設定することで行えます。また、GridWebコントロールのEnableClientFreeze属性をfalseに設定することで、ユーザーが行や列を固定することも制限することが可能です。
行と列のオプションを制限した後のコンテキストメニュー
For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Accessing the first worksheet that is currently active | |
GridWorksheet sheet = gridweb.getWorkSheets().get(gridweb.getActiveSheetIndex()); | |
//Restricting column related operations in context menu | |
gridweb.setEnableClientColumnOperations(false); | |
//Restricting row related operations in context menu | |
gridweb.setEnableClientRowOperations(false); | |
//Restricting freeze option of context menu | |
gridweb.setEnableClientFreeze(false); | |