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