[]
        
(Showing Draft Content)

セル型の設定

セル型は、個々のセル、セル範囲、列、行、また名前付きスタイルを使用するとシート全体に対して設定できます。セル型についても「オブジェクトの親子関係」が適用され、セルレベルで設定されたセル型の優先順位が最も高くなります。

設定方法

適用するセル型を作成し、各オブジェクトや、名前付きスタイルのCellType プロパティに設定します。CellType プロパティを搭載するオブジェクトは以下のとおりです。

オブジェクト

クラス

プロパティ

セル

Cell クラス

CellType プロパティ

列

Column クラス

CellType プロパティ

行

Row クラス

CellType プロパティ

1行おきの行

AlternatingRow クラス

CellType プロパティ

名前付きスタイル

NamedStyle クラス

CellType プロパティ

また、セルにどのセル型が設定されているか調ベるには、SheetView クラスのGetCellType メソッドを使用します。Visual Basicの場合はTypeOf...Is式、C#の場合はis演算子を使用することでセル型を確認できます。

サンプルコード

次のサンプルコードは、行、列および特定のセルにセル型を設定する例です。

// 先頭行全体に標準型セルを設定します
fpSpread1.ActiveSheet.Rows[0].CellType = new FarPoint.Win.Spread.CellType.GeneralCellType();

// 2列目全体にボタン型セルを設定します
FarPoint.Win.Spread.CellType.ButtonCellType buttonCell = new FarPoint.Win.Spread.CellType.ButtonCellType();
buttonCell.Text = "ボタン";
fpSpread1.ActiveSheet.Columns[1].CellType = buttonCell;

// 先頭行1列目のセルのみ日付型セルを設定します
FarPoint.Win.Spread.CellType.DateTimeCellType datecell = new FarPoint.Win.Spread.CellType.DateTimeCellType();
datecell.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.ShortDate;
fpSpread1.ActiveSheet.Cells[0, 0].CellType = datecell;
fpSpread1.ActiveSheet.Cells[0, 0].Value = System.DateTime.Now;
' 先頭行全体に標準型セルを設定します
FpSpread1.ActiveSheet.Rows(0).CellType = New FarPoint.Win.Spread.CellType.GeneralCellType()

' 2列目全体にボタン型セルを設定します
Dim buttonCell As New FarPoint.Win.Spread.CellType.ButtonCellType()
buttonCell.Text = "ボタン"
FpSpread1.ActiveSheet.Columns(1).CellType = buttonCell

' 先頭行1列目のセルのみ日付型セルを設定します
Dim datecell As New FarPoint.Win.Spread.CellType.DateTimeCellType()
datecell.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.ShortDate
FpSpread1.ActiveSheet.Cells(0, 0).CellType = datecell
FpSpread1.ActiveSheet.Cells(0, 0).Value = System.DateTime.Now

参照

セル型

セル型の概要

データの表示

モデルに書き込まれるデータ型

編集可能なセル型

グラフィカルなセル型

InputManセル

セル型の拡張設定

セル型

セル型の概要

データの表示

モデルに書き込まれるデータ型

編集可能なセル型

グラフィカルなセル型

InputManセル

セル型の拡張設定