Spread - デザイン
セルのフォントを変更したい
Spreadには、セルの表示形式を設定するためのSpreadStyleクラスがあります。
セルのフォントはSpreadStyleクラスのfontプロパティ、セルの文字色はfgColorプロパティを
利用して設定します。
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; /* セルのフォント設定 */ var f = new font("メイリオ",10); /* A1セルにスタイル(フォント)を設定 */ var s = new SpreadStyle; s.font = f; s.fgColor = 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; /* セルのフォント設定(打ち消し線あり) */ var f = new font("Times New Roman",12, false, false, false, true); /* 3行目にスタイル(フォント)を設定 */ var s = new SpreadStyle; s.font = f; var r = rows(3); r.style = s; /* 選択状態に設定 */ addSelection(r); } Spread spread3 { x = 24; y = 272; width = 336; height = 191; maxRows = 4; maxColumns = 4; /* セルのフォント設定(太字、斜体) */ var f = new font("MS 明朝",14, true, true); /* D列にスタイル(フォント)を設定 */ var s = new SpreadStyle; s.font = f; var c = columns("D"); c.style = s; /* 選択状態に設定 */ addSelection(c); } Spread spread4 { x = 384; y = 272; width = 336; height = 191; maxRows = 4; maxColumns = 4; /* セルのフォント設定(下線あり) */ var f = new font("Meiryo UI",8, false, false, true, false); /* ブロック(A1からC3)にスタイル(フォント)を設定 */ var s = new SpreadStyle; s.font = f; s.fgColor = 0xff000080; var r = range("A1:C3"); r.style = s; /* 選択状態に設定 */ addSelection(r); } 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集 トップへ