列の幅または行の高さの設定
Contents
[
Hide
]
このトピックでは、Aspose.Cells.GridDesktop API を使用して列の幅と行の高さを設定する方法について説明します。ワークシートのセルには、元のセルよりも幅の広い値が含まれている場合があります。ユーザーがセルの内容を読むのが難しくなります。一部のユーザーは、右矢印キーを使用してセル内の完全な値を表示することを好みません。このような問題を解決するために、開発者は列幅を変更できます。行の高さを変更すると、同様の問題が解決されます。
列幅の設定
Aspose.Cells.GridDesktop を使用して列の幅を設定するには:
- ワークシートにアクセスします。
- 幅を変更する列にアクセスします。
- 列幅を設定します。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Accessing the worksheet of the Grid that is currently active | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Adding sample value to sheet cell | |
GridCell cell = sheet.Cells["a1"]; | |
cell.SetCellValue("Welcome to Aspose!"); | |
// Accessing the first column of the worksheet | |
Aspose.Cells.GridDesktop.Data.GridColumn column = sheet.Columns[0]; | |
// Setting the width of the column | |
column.Width = 150; |
行の高さの設定
Aspose.Cells.GridDesktop を使用して行の高さを設定するには、次の手順に従ってください。
- 必要なワークシートにアクセスします。
- 高さを変更する行にアクセスします。
- 行の高さを設定します。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Accessing the worksheet of the Grid that is currently active | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Adding sample value to sheet cells | |
GridCell cell = sheet.Cells["b2"]; | |
cell.SetCellValue("1"); | |
cell = sheet.Cells["c2"]; | |
cell.SetCellValue("2"); | |
cell = sheet.Cells["d2"]; | |
cell.SetCellValue("3"); | |
cell = sheet.Cells["e2"]; | |
cell.SetCellValue("4"); | |
// Accessing the first row of the worksheet | |
Aspose.Cells.GridDesktop.Data.GridRow row = sheet.Rows[1]; | |
// Setting the height of the row | |
row.Height = 100; |