コマンドバーのテーマ

SPREADでは、4種類のコマンドバーのアイコンテーマが用意されています。 シートスキンと組み合わせて使用することで、簡単にデザインを設定することができます。
テーマ スキン
 ID氏名カナ生年月日性別血液型部署入社日メールアドレス
11001亀甲 滋万キコウ シゲマ1950/02/04A人事部1972/04/01sigema_kikou@abc.co.jp
21002寒田 希世カンダ キヨ1959/06/28B人事部1981/04/01kiyo_kanda@bbb.or.jp
31003小和瀬 澄オワセ キヨ1969/03/06A人事部1991/04/01kiyo_owase@aaa.co.jp
41004宇夫 早余子ウブ サヨコ1976/07/28O人事部1998/04/01sayoko_ubu@bbb.or.jp
51005宇田津 聖智ウダツ キヨトモ1965/09/04A営業部1987/04/01kiyotomo_udatu@abc.co.jp
61006茨城 昭児イバラキ ショウジ1963/04/28O営業部1985/04/01shouzi_ibaraki@xyz.ne.jp
71007石ヶ休 椎茄イシガキュウ シイナ1953/02/21O営業部1975/04/01siina_isigagyuu@abc.co.jp
81008赤司 恵治郎アカツカサ ケイジロウ1968/08/02O経理部1990/04/01keizirou_akatukasa@abc.co.jp
91009小橋 仰一オハシ ギョウイチ1972/03/02B経理部1994/04/01gyouiti_ohasi@abc.co.jp
101010一重 公大イチジュウ コウダイ1964/04/19B経理部1986/04/01koudai_itizyuu@xyz.ne.jp
     

ソースコード

別ウィンドウで表示
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class commandbar_commandbartheme : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string js = "var spid='" + FpSpread1.ClientID + "';";
        ClientScript.RegisterStartupScript(this.GetType(), "onStartUpScript", js, true);

        // クライアント側スクリプトの設定
        string clientScript = "<script language=\"JavaScript\">";
        clientScript += "function SetSkin(val)";
        clientScript += "{";
        clientScript += "var spread = document.getElementById(\"" + FpSpread1.ClientID + "\");";
        clientScript += "spread.CallBack(\"SetSkin.\"+val);";
        clientScript += "}";
        clientScript += "</script>";

        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "sheetskinScript", clientScript, false);

        if (IsPostBack)
        {
            return;
        }

        // SPREADの設定
        InitSpread(FpSpread1);

        // シート設定
        InitSpreadStyles(FpSpread1.Sheets[0]);

        // ドロップダウンリスト初期化
        InitSkinDDL();
    }

    private void InitSpread(FarPoint.Web.Spread.FpSpread spread)
    {
        spread.CssClass = "spreadStyle";
        spread.UseClipboard = false;
        spread.CommandBar.ShowPDFButton = true;

        // データ連結
        System.Data.DataSet ds = new System.Data.DataSet();
        ds.ReadXml(MapPath("../App_Data/data50.xml"));
        spread.DataSource = ds;
    }

    private void InitSpreadStyles(FarPoint.Web.Spread.SheetView sheet)
    {
        // フォントサイズの設定
        sheet.DefaultStyle.Font.Size = FontUnit.Parse("80%");
        sheet.ColumnHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%");
        sheet.RowHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%");
        sheet.SheetCorner.DefaultStyle.Font.Size = FontUnit.Parse("80%");

        //列幅の設定
        sheet.Columns[0].Width = 45;
        sheet.Columns[1].Width = 85;
        sheet.Columns[2].Width = 120;
        sheet.Columns[3].Width = 80;
        sheet.Columns[4].Width = 50;
        sheet.Columns[5].Width = 50;
        sheet.Columns[6].Width = 65;
        sheet.Columns[7].Width = 80;
        sheet.Columns[8].Width = 140;

        // 縦方向の揃え位置を中央に設定
        sheet.DefaultStyle.VerticalAlign = VerticalAlign.Middle;

        sheet.AllowDelete = true;
        sheet.AllowInsert = true;
    }

    private void InitSkinDDL()
    {
        // 組み込みスキン名表示
        int idx = 0;
        foreach (FarPoint.Web.Spread.SheetSkin fpskin in FarPoint.Web.Spread.DefaultSkins.Skins)
        {
            DDLSkin.Items.Add(new ListItem(fpskin.Name, Convert.ToString(idx)));
            idx = idx + 1;
        }
    }

    protected void FpSpread1_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
    {
        if (e.CommandName.StartsWith("setCommandBarTheme"))
        {
            string[] strCom = e.CommandName.Split('_');
            string CommandBarTheme = Convert.ToString(strCom[1]);

            // コマンドバーのテーマを変更
            if (CommandBarTheme == "NotSet")
            {
                FpSpread1.CommandBar.Theme = FarPoint.Web.Spread.ImageButtonTheme.NotSet;
            }
            else if (CommandBarTheme == "Xp")
            {
                FpSpread1.CommandBar.Theme = FarPoint.Web.Spread.ImageButtonTheme.Xp;
            }
            else if (CommandBarTheme == "Vista")
            {
                FpSpread1.CommandBar.Theme = FarPoint.Web.Spread.ImageButtonTheme.Vista;
            }
            else if (CommandBarTheme == "Office2007")
            {
                FpSpread1.CommandBar.Theme = FarPoint.Web.Spread.ImageButtonTheme.Office2007;
            }
            else if (CommandBarTheme == "Classic")
            {
                FpSpread1.CommandBar.Theme = FarPoint.Web.Spread.ImageButtonTheme.Classic;
            }
            else if (CommandBarTheme == "Office2016") {
                FpSpread1.CommandBar.Theme = FarPoint.Web.Spread.ImageButtonTheme.Office2016;

            }
        }

        if (e.CommandName.StartsWith("SetSkin"))
        {
            string[] strCom = e.CommandName.Split('.');

            FarPoint.Web.Spread.DefaultSkins.GetAt(Convert.ToInt16(strCom[1])).Apply(FpSpread1.ActiveSheetView);

            // フォントサイズの設定
            FpSpread1.ActiveSheetView.DefaultStyle.Font.Size = FontUnit.Parse("80%");
            FpSpread1.ActiveSheetView.ColumnHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%");
            FpSpread1.ActiveSheetView.RowHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%");
        }
    }
}

Partial Class commandbar_commandbartheme
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim js As String = "var spid='" + FpSpread1.ClientID & "';"
        ClientScript.RegisterStartupScript(Me.GetType(), "onStartUpScript", js, True)

        ' クライアント側スクリプトの設定
        Dim clientScript__1 As String = "<script language=""JavaScript"">"
        clientScript__1 += "function SetSkin(val)"
        clientScript__1 += "{"
        clientScript__1 += "var spread = document.getElementById(""" + FpSpread1.ClientID & """);"
        clientScript__1 += "spread.CallBack(""SetSkin.""+val);"
        clientScript__1 += "}"
        clientScript__1 += "</script>"

        ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "sheetskinScript", clientScript__1, False)

        If IsPostBack Then
            Return
        End If

        ' SPREADの設定
        InitSpread(FpSpread1)

        ' シート設定
        InitSpreadStyles(FpSpread1.Sheets(0))

        ' ドロップダウンリスト初期化
        InitSkinDDL()
    End Sub

    Private Sub InitSpread(ByVal spread As FarPoint.Web.Spread.FpSpread)
        spread.CssClass = "spreadStyle"
        spread.UseClipboard = False
        spread.CommandBar.ShowPDFButton = True

        ' データ連結
        Dim ds As New System.Data.DataSet()
        ds.ReadXml(MapPath("../App_Data/data50.xml"))
        spread.DataSource = ds
    End Sub

    Private Sub InitSpreadStyles(ByVal sheet As FarPoint.Web.Spread.SheetView)
        ' フォントサイズの設定
        sheet.DefaultStyle.Font.Size = FontUnit.Parse("80%")
        sheet.ColumnHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%")
        sheet.RowHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%")
        sheet.SheetCorner.DefaultStyle.Font.Size = FontUnit.Parse("80%")

        '列幅の設定
        sheet.Columns(0).Width = 45
        sheet.Columns(1).Width = 85
        sheet.Columns(2).Width = 120
        sheet.Columns(3).Width = 80
        sheet.Columns(4).Width = 50
        sheet.Columns(5).Width = 50
        sheet.Columns(6).Width = 65
        sheet.Columns(7).Width = 80
        sheet.Columns(8).Width = 140

        ' 縦方向の揃え位置を中央に設定
        sheet.DefaultStyle.VerticalAlign = VerticalAlign.Middle

        sheet.AllowDelete = True
        sheet.AllowInsert = True
    End Sub

    Private Sub InitSkinDDL()
        ' 組み込みスキン名表示
        Dim idx As Integer = 0
        For Each fpskin As FarPoint.Web.Spread.SheetSkin In FarPoint.Web.Spread.DefaultSkins.Skins
            DDLSkin.Items.Add(New ListItem(fpskin.Name, Convert.ToString(idx)))
            idx = idx + 1
        Next
    End Sub

    Protected Sub FpSpread1_ButtonCommand(ByVal sender As Object, ByVal e As FarPoint.Web.Spread.SpreadCommandEventArgs) Handles FpSpread1.ButtonCommand
        If e.CommandName.StartsWith("setCommandBarTheme") Then
            Dim strCom As String() = e.CommandName.Split("_"c)
            Dim CommandBarTheme As String = Convert.ToString(strCom(1))

            ' コマンドバーのテーマを変更
            If CommandBarTheme = "NotSet" Then
                FpSpread1.CommandBar.Theme = FarPoint.Web.Spread.ImageButtonTheme.NotSet
            ElseIf CommandBarTheme = "Xp" Then
                FpSpread1.CommandBar.Theme = FarPoint.Web.Spread.ImageButtonTheme.Xp
            ElseIf CommandBarTheme = "Vista" Then
                FpSpread1.CommandBar.Theme = FarPoint.Web.Spread.ImageButtonTheme.Vista
            ElseIf CommandBarTheme = "Office2007" Then
                FpSpread1.CommandBar.Theme = FarPoint.Web.Spread.ImageButtonTheme.Office2007
            ElseIf CommandBarTheme = "Office2016" Then
                FpSpread1.CommandBar.Theme = FarPoint.Web.Spread.ImageButtonTheme.Office2016
            ElseIf CommandBarTheme = "Classic" Then
                FpSpread1.CommandBar.Theme = FarPoint.Web.Spread.ImageButtonTheme.Classic
            End If
        End If

        If e.CommandName.StartsWith("SetSkin") Then
            Dim strCom As String() = e.CommandName.Split("."c)

            FarPoint.Web.Spread.DefaultSkins.GetAt(Convert.ToInt16(strCom(1))).Apply(FpSpread1.ActiveSheetView)

            ' フォントサイズの設定
            FpSpread1.ActiveSheetView.DefaultStyle.Font.Size = FontUnit.Parse("80%")
            FpSpread1.ActiveSheetView.ColumnHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%")
            FpSpread1.ActiveSheetView.RowHeader.DefaultStyle.Font.Size = FontUnit.Parse("80%")
        End If
    End Sub
End Class

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" 
    CodeFile="commandbartheme.aspx.cs" Inherits="commandbar_commandbartheme" %>

<%@ Register Assembly="FarPoint.Web.SpreadJ" Namespace="FarPoint.Web.Spread" TagPrefix="FarPoint" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeaderPlaceHolder1" Runat="Server">
<script type="text/javascript">
    function setCommandBarTheme(theme) {
        var spread = document.getElementById(spid);
        spread.CallBack("setCommandBarTheme_" + theme);
    }   
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">    
    <table>
        <tr>
            <td>
            <asp:Label ID="Label1" runat="server" Text="テーマ"></asp:Label>
            <select id="Select1" onchange="setCommandBarTheme(this[this.selectedIndex].text + '_0');">
                <option value="NotSet">NotSet</option>
                <option value="Xp">Xp</option>
                <option value="Vista">Vista</option>
                <option value="Office2007">Office2007</option>
                <option value="Office2016">Office2016</option>
                <option value="Classic">Classic</option>
            </select>
            </td>
            <td>
            <asp:Label ID="Label2" runat="server" Text="スキン"></asp:Label>
            <asp:DropDownList ID="DDLSkin" runat="server" onchange="SetSkin(this[this.selectedIndex].value);">
            </asp:DropDownList>
            </td>
        </tr>
    </table>
    <FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="#A0A0A0" BorderStyle="Solid"
        BorderWidth="1px" onbuttoncommand="FpSpread1_ButtonCommand">
        <CommandBar BackColor="Control" ButtonFaceColor="Control" ButtonHighlightColor="ControlLightLight"
            ButtonShadowColor="ControlDark">
        </CommandBar>
        <Sheets>
            <FarPoint:SheetView SheetName="Sheet1">
            </FarPoint:SheetView>
        </Sheets>
    </FarPoint:FpSpread>
</asp:Content>