行または列にスタイルを適用
Contents
[
Hide
]
このトピックでは、Aspose.Cells.GridDesktop が提供する基本的なフォーマット機能であるワークシートの行や列のフォントとフォントの色を変更する方法について説明します。
列にスタイルを適用する
Aspose.Cells.GridDesktopを使用して列にカスタムスタイルを適用するには、以下の手順に従ってください:
- 任意の Worksheet にアクセスします
- 適用したい スタイル を適用する 列 にアクセス
- 列 の スタイル を取得
- カスタムの必要に応じて スタイル プロパティを設定
- 最後に、更新されたもので 列 の スタイル を設定
Style オブジェクトが提供する多くの便利なプロパティとメソッドを使用して、開発者が要件に応じてスタイルをカスタマイズできます。
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(); | |
// Accessing the first column of the worksheet | |
Aspose.Cells.GridDesktop.Data.GridColumn column = sheet.Columns[0]; | |
// Adding sample value to sheet cell | |
GridCell cell = sheet.Cells["a1"]; | |
cell.SetCellValue("Aspose"); | |
// Getting the Style object for the column | |
Style style = column.GetStyle(); | |
// Setting Style properties i.e. border, alignment color etc. | |
style.SetBorderLine(BorderType.Right, BorderLineType.Thick); | |
style.SetBorderColor(BorderType.Right, Color.Blue); | |
style.HAlignment = HorizontalAlignmentType.Centred; | |
// Setting the style of the column with the customized Style object | |
column.SetStyle(style); |
行にスタイルを適用
Aspose.Cells.GridDesktop を使用して行にカスタムスタイルを適用するには、以下の手順に従ってください
- 任意の Worksheet にアクセスします
- 適用したい スタイル を適用する 行 にアクセス
- 行 の スタイル を取得
- カスタムの必要に応じて スタイル プロパティを設定
- 最後に、更新されたもので 行 の スタイル を設定
Style オブジェクトが提供する多くの便利なプロパティとメソッドを使用して、開発者が要件に応じてスタイルをカスタマイズできます。
// Accessing the worksheet of the Grid that is currently active
Worksheet sheet = gridDesktop1.GetActiveWorksheet();
// Accessing the first row of the worksheet
Aspose.Cells.GridDesktop.Data.GridRow row = sheet.Rows[0];
// Getting the Style object for the row
Style style = row.GetStyle();
// Setting Style properties i.e. border, color, alignment, background color etc.
style.SetBorderLine(BorderType.Right, BorderLineType.Thick);
style.SetBorderColor(BorderType.Right, Color.Blue);
style.HAlignment = HorizontalAlignmentType.Centred;
style.Color = Color.Yellow;
// Setting the style of the row with the customized Style object
row.SetStyle(style);