MESCIUS SPREAD for Windows Forms 15.0J サンプルコード集 > セル型 > セルデータが存在しない場合に任意の文字列を表示させる |
NullDisplayプロパティの使用により、セルデータが存在しない場合の値を設定することができます。未入力状態をブランクではなく明示的に示したい場合などに有効です。
private void Form1_Load(object sender, System.EventArgs e) { //1列目にテキスト型セルを設定します FarPoint.Win.Spread.CellType.TextCellType txtcell = new FarPoint.Win.Spread.CellType.TextCellType(); txtcell.NullDisplay = "未入力"; fpSpread1.ActiveSheet.Columns[0].CellType = txtcell; fpSpread1.ActiveSheet.Columns[0].Width = 100; //2列目に数値型セルを設定します FarPoint.Win.Spread.CellType.NumberCellType nmbrcell = new FarPoint.Win.Spread.CellType.NumberCellType(); nmbrcell.NullDisplay = "0"; nmbrcell.DecimalPlaces = 0; fpSpread1.ActiveSheet.Columns[1].CellType = nmbrcell; fpSpread1.ActiveSheet.Cells[0, 0].Value = "光学式マウス"; fpSpread1.ActiveSheet.Cells[3, 0].Value = "液晶ディスプレイ"; fpSpread1.ActiveSheet.Cells[7, 0].Value = "日本語キーボード"; fpSpread1.ActiveSheet.Cells[1, 1].Value = "1000"; fpSpread1.ActiveSheet.Cells[3, 1].Value = "2000"; fpSpread1.ActiveSheet.Cells[6, 1].Value = "3000"; }
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load '1列目にテキスト型セルを設定します Dim txtcell As New FarPoint.Win.Spread.CellType.TextCellType() txtcell.NullDisplay = "未入力" FpSpread1.ActiveSheet.Columns(0).CellType = txtcell FpSpread1.ActiveSheet.Columns(0).Width = 100 '2列目に数値型セルを設定します Dim nmbrcell As New FarPoint.Win.Spread.CellType.NumberCellType() nmbrcell.NullDisplay = 0 nmbrcell.DecimalPlaces = 0 FpSpread1.ActiveSheet.Columns(1).CellType = nmbrcell FpSpread1.ActiveSheet.Cells(0, 0).Value = "光学式マウス" FpSpread1.ActiveSheet.Cells(3, 0).Value = "液晶ディスプレイ" FpSpread1.ActiveSheet.Cells(7, 0).Value = "日本語キーボード" FpSpread1.ActiveSheet.Cells(1, 1).Value = "1000" FpSpread1.ActiveSheet.Cells(3, 1).Value = "2000" FpSpread1.ActiveSheet.Cells(6, 1).Value = "3000" End Sub