Spread - デザイン
セルの背景色を設定したい
Spreadには、セルの表示形式を設定するためのSpreadStyleクラスがあります。
セルの背景色はSpreadStyleクラスのbgColorプロパティを利用して設定します。
SpreadStyleクラスはSpread全体だけでなく、セル単位、行・列単位、ブロック単位で
設定することも可能です。
【実行結果@】
【実行結果A】
【実行結果B】
【実行結果C】
Form form1 { x = 0; y = 0; width = 800; height = 513; CSVDocument csvdata; csvdata << CSV{ s001,田中太郎,たなかたろう,営業部 s002,鈴木一郎,すずきいちろう,開発部 s003,佐藤次郎,さとうじろう,総務部 s004,山田花子,やまだはなこ,経理部}; Spread spread1 { x = 24; y = 40; width = 336; height = 191; maxRows = 4; maxColumns = 4; /* A1セルにスタイル(背景色)を設定 */ var s = new SpreadStyle; s.bgColor = Color.RED; var c = cell("A1"); c.style = s; /* 選択状態に設定 */ addSelection(c); } Spread spread2 { x = 384; y = 40; width = 336; height = 191; maxRows = 4; maxColumns = 4; /* 2行目にスタイル(背景色)を設定 */ var s = new SpreadStyle; s.bgColor = Color.GREEN; var r = rows(2); r.style = s; /* 選択状態に設定 */ addSelection(r); } Spread spread3 { x = 24; y = 272; width = 336; height = 191; maxRows = 4; maxColumns = 4; /* C列にスタイル(背景色)を設定 */ var s = new SpreadStyle; s.bgColor = Color.CYAN; var c = columns("C"); c.style = s; /* 選択状態に設定 */ addSelection(c); } Spread spread4 { x = 384; y = 272; width = 336; height = 191; maxRows = 4; maxColumns = 4; /* ブロック(A1からC3)にスタイル(背景色)を設定 */ var s = new SpreadStyle; s.bgColor = Color.YELLOW; var r = range("A1:C3"); r.style = s; /* 選択状態に設定 */ range("A1:C3").select(); } Label label1 { x = 24; y = 24; width = 336; height = 16; value = "セル単位で背景色を設定"; } Label label2 { x = 384; y = 24; width = 336; height = 16; value = "行単位で背景色を設定"; } Label label3 { x = 24; y = 256; width = 336; height = 16; value = "列単位で背景色を設定"; } Label label4 { x = 384; y = 256; width = 336; height = 16; value = "ブロック単位で背景色を設定"; } if (!Application.DESIGNTIME) { /* CSVデータを各Spreadにロード */ spread1 << csvdata; spread2 << csvdata; spread3 << csvdata; spread4 << csvdata; } }
Biz-Collections Bizの宝箱 トップへ
Biz/Browser DT・Biz/Designer DT TIPS集 トップへ