シートコーナーセルの分割

列ヘッダと行ヘッダが交差するシートコーナーセルを分割して表示することができます。
分割したシートコーナーセルに任意もテキストや、スタイル(背景色など)を設定することができます。
グレープシティ商事項目A項目B
NO支店ID A担当中項目1中項目2中項目3中項目1中項目2中項目3
ID B小項目1小項目2小項目3小項目1小項目2小項目3
1札幌1001佐藤      
1002      
22001山本      
2002      
33001石川      
3002      
4千葉1001鈴木      
1002      
5広島1001田中      
1002      
62001橋本      
2002      
   

ソースコード

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

public partial class rowcolcell_sheetcorner : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            return;
        }

        // SPREADの設定
        InitSpread(FpSpread1);

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

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

    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.DefaultStyle.VerticalAlign = VerticalAlign.Middle;

        sheet.ColumnCount = 6;
        sheet.RowCount = 12;
        sheet.PageSize = 12;

        // 列ヘッダの設定
        sheet.ColumnHeader.RowCount = 3;
        sheet.ColumnHeader.Cells[0, 0].Value = "項目A";
        sheet.ColumnHeader.Cells[0, 3].Value = "項目B";
        sheet.ColumnHeader.Cells[0, 0].ColumnSpan = 3;
        sheet.ColumnHeader.Cells[0, 3].ColumnSpan = 3;
        sheet.ColumnHeader.Cells[1, 0].Value = "中項目1";
        sheet.ColumnHeader.Cells[1, 1].Value = "中項目2";
        sheet.ColumnHeader.Cells[1, 2].Value = "中項目3";
        sheet.ColumnHeader.Cells[1, 3].Value = "中項目1";
        sheet.ColumnHeader.Cells[1, 4].Value = "中項目2";
        sheet.ColumnHeader.Cells[1, 5].Value = "中項目3";
        sheet.ColumnHeader.Cells[2, 0].Value = "小項目1";
        sheet.ColumnHeader.Cells[2, 1].Value = "小項目2";
        sheet.ColumnHeader.Cells[2, 2].Value = "小項目3";
        sheet.ColumnHeader.Cells[2, 3].Value = "小項目1";
        sheet.ColumnHeader.Cells[2, 4].Value = "小項目2";
        sheet.ColumnHeader.Cells[2, 5].Value = "小項目3";

        // 行ヘッダの設定
        sheet.RowHeader.ColumnCount = 4;
        sheet.RowHeader.Cells[0, 0].Value = "1";
        sheet.RowHeader.Cells[2, 0].Value = "2";
        sheet.RowHeader.Cells[4, 0].Value = "3";
        sheet.RowHeader.Cells[6, 0].Value = "4";
        sheet.RowHeader.Cells[8, 0].Value = "5";
        sheet.RowHeader.Cells[10, 0].Value = "6";
        sheet.RowHeader.Cells[0, 0].RowSpan = 2;
        sheet.RowHeader.Cells[2, 0].RowSpan = 2;
        sheet.RowHeader.Cells[4, 0].RowSpan = 2;
        sheet.RowHeader.Cells[6, 0].RowSpan = 2;
        sheet.RowHeader.Cells[8, 0].RowSpan = 2;
        sheet.RowHeader.Cells[10, 0].RowSpan = 2;
        sheet.RowHeader.Cells[0, 1].Value = "札幌";
        sheet.RowHeader.Cells[6, 1].Value = "千葉";
        sheet.RowHeader.Cells[8, 1].Value = "広島";
        sheet.RowHeader.Cells[0, 1].RowSpan = 6;
        sheet.RowHeader.Cells[6, 1].RowSpan = 2;
        sheet.RowHeader.Cells[8, 1].RowSpan = 4;
        sheet.RowHeader.Cells[0, 2].Value = "1001";
        sheet.RowHeader.Cells[1, 2].Value = "1002";
        sheet.RowHeader.Cells[2, 2].Value = "2001";
        sheet.RowHeader.Cells[3, 2].Value = "2002";
        sheet.RowHeader.Cells[4, 2].Value = "3001";
        sheet.RowHeader.Cells[5, 2].Value = "3002";
        sheet.RowHeader.Cells[6, 2].Value = "1001";
        sheet.RowHeader.Cells[7, 2].Value = "1002";
        sheet.RowHeader.Cells[8, 2].Value = "1001";
        sheet.RowHeader.Cells[9, 2].Value = "1002";
        sheet.RowHeader.Cells[10, 2].Value = "2001";
        sheet.RowHeader.Cells[11, 2].Value = "2002";
        sheet.RowHeader.Cells[0, 3].Value = "佐藤";
        sheet.RowHeader.Cells[2, 3].Value = "山本";
        sheet.RowHeader.Cells[4, 3].Value = "石川";
        sheet.RowHeader.Cells[6, 3].Value = "鈴木";
        sheet.RowHeader.Cells[8, 3].Value = "田中";
        sheet.RowHeader.Cells[10, 3].Value = "橋本";
        sheet.RowHeader.Cells[0, 3].RowSpan = 2;
        sheet.RowHeader.Cells[2, 3].RowSpan = 2;
        sheet.RowHeader.Cells[4, 3].RowSpan = 2;
        sheet.RowHeader.Cells[6, 3].RowSpan = 2;
        sheet.RowHeader.Cells[8, 3].RowSpan = 2;
        sheet.RowHeader.Cells[10, 3].RowSpan = 2;

        // シートコーナーを分割
        sheet.AllowTableCorner = true;
        sheet.SheetCorner.Cells[0, 0].Value = "グレープシティ商事";
        sheet.SheetCorner.Cells[0, 0].ColumnSpan = 4;
        sheet.SheetCorner.Cells[1, 0].Value = "NO";
        sheet.SheetCorner.Cells[1, 1].Value = "支店";
        sheet.SheetCorner.Cells[1, 2].Value = "ID A";
        sheet.SheetCorner.Cells[2, 2].Value = "ID B";
        sheet.SheetCorner.Cells[1, 3].Value = "担当";
        sheet.SheetCorner.Cells[1, 0].RowSpan = 2;
        sheet.SheetCorner.Cells[1, 1].RowSpan = 2;
        sheet.SheetCorner.Cells[1, 3].RowSpan = 2;
        sheet.SheetCorner.Cells[1, 2].ForeColor = System.Drawing.Color.Red;
        sheet.SheetCorner.Cells[2, 2].ForeColor = System.Drawing.Color.Green;
    }
}
Partial Class rowcolcell_sheetcorner
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If IsPostBack Then
            Return
        End If

        ' SPREADの設定
        InitSpread(FpSpread1)

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

    Private Sub InitSpread(ByVal spread As FarPoint.Web.Spread.FpSpread)
        spread.CssClass = "spreadStyle"
        spread.UseClipboard = False
    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.DefaultStyle.VerticalAlign = VerticalAlign.Middle

        sheet.ColumnCount = 6
        sheet.RowCount = 12
        sheet.PageSize = 12

        ' 列ヘッダの設定
        sheet.ColumnHeader.RowCount = 3
        sheet.ColumnHeader.Cells(0, 0).Value = "項目A"
        sheet.ColumnHeader.Cells(0, 3).Value = "項目B"
        sheet.ColumnHeader.Cells(0, 0).ColumnSpan = 3
        sheet.ColumnHeader.Cells(0, 3).ColumnSpan = 3
        sheet.ColumnHeader.Cells(1, 0).Value = "中項目1"
        sheet.ColumnHeader.Cells(1, 1).Value = "中項目2"
        sheet.ColumnHeader.Cells(1, 2).Value = "中項目3"
        sheet.ColumnHeader.Cells(1, 3).Value = "中項目1"
        sheet.ColumnHeader.Cells(1, 4).Value = "中項目2"
        sheet.ColumnHeader.Cells(1, 5).Value = "中項目3"
        sheet.ColumnHeader.Cells(2, 0).Value = "小項目1"
        sheet.ColumnHeader.Cells(2, 1).Value = "小項目2"
        sheet.ColumnHeader.Cells(2, 2).Value = "小項目3"
        sheet.ColumnHeader.Cells(2, 3).Value = "小項目1"
        sheet.ColumnHeader.Cells(2, 4).Value = "小項目2"
        sheet.ColumnHeader.Cells(2, 5).Value = "小項目3"

        ' 行ヘッダの設定
        sheet.RowHeader.ColumnCount = 4
        sheet.RowHeader.Cells(0, 0).Value = "1"
        sheet.RowHeader.Cells(2, 0).Value = "2"
        sheet.RowHeader.Cells(4, 0).Value = "3"
        sheet.RowHeader.Cells(6, 0).Value = "4"
        sheet.RowHeader.Cells(8, 0).Value = "5"
        sheet.RowHeader.Cells(10, 0).Value = "6"
        sheet.RowHeader.Cells(0, 0).RowSpan = 2
        sheet.RowHeader.Cells(2, 0).RowSpan = 2
        sheet.RowHeader.Cells(4, 0).RowSpan = 2
        sheet.RowHeader.Cells(6, 0).RowSpan = 2
        sheet.RowHeader.Cells(8, 0).RowSpan = 2
        sheet.RowHeader.Cells(10, 0).RowSpan = 2
        sheet.RowHeader.Cells(0, 1).Value = "札幌"
        sheet.RowHeader.Cells(6, 1).Value = "千葉"
        sheet.RowHeader.Cells(8, 1).Value = "広島"
        sheet.RowHeader.Cells(0, 1).RowSpan = 6
        sheet.RowHeader.Cells(6, 1).RowSpan = 2
        sheet.RowHeader.Cells(8, 1).RowSpan = 4
        sheet.RowHeader.Cells(0, 2).Value = "1001"
        sheet.RowHeader.Cells(1, 2).Value = "1002"
        sheet.RowHeader.Cells(2, 2).Value = "2001"
        sheet.RowHeader.Cells(3, 2).Value = "2002"
        sheet.RowHeader.Cells(4, 2).Value = "3001"
        sheet.RowHeader.Cells(5, 2).Value = "3002"
        sheet.RowHeader.Cells(6, 2).Value = "1001"
        sheet.RowHeader.Cells(7, 2).Value = "1002"
        sheet.RowHeader.Cells(8, 2).Value = "1001"
        sheet.RowHeader.Cells(9, 2).Value = "1002"
        sheet.RowHeader.Cells(10, 2).Value = "2001"
        sheet.RowHeader.Cells(11, 2).Value = "2002"
        sheet.RowHeader.Cells(0, 3).Value = "佐藤"
        sheet.RowHeader.Cells(2, 3).Value = "山本"
        sheet.RowHeader.Cells(4, 3).Value = "石川"
        sheet.RowHeader.Cells(6, 3).Value = "鈴木"
        sheet.RowHeader.Cells(8, 3).Value = "田中"
        sheet.RowHeader.Cells(10, 3).Value = "橋本"
        sheet.RowHeader.Cells(0, 3).RowSpan = 2
        sheet.RowHeader.Cells(2, 3).RowSpan = 2
        sheet.RowHeader.Cells(4, 3).RowSpan = 2
        sheet.RowHeader.Cells(6, 3).RowSpan = 2
        sheet.RowHeader.Cells(8, 3).RowSpan = 2
        sheet.RowHeader.Cells(10, 3).RowSpan = 2

        ' シートコーナーを分割
        sheet.AllowTableCorner = True
        sheet.SheetCorner.Cells(0, 0).Value = "グレープシティ商事"
        sheet.SheetCorner.Cells(0, 0).ColumnSpan = 4
        sheet.SheetCorner.Cells(1, 0).Value = "NO"
        sheet.SheetCorner.Cells(1, 1).Value = "支店"
        sheet.SheetCorner.Cells(1, 2).Value = "ID A"
        sheet.SheetCorner.Cells(2, 2).Value = "ID B"
        sheet.SheetCorner.Cells(1, 3).Value = "担当"
        sheet.SheetCorner.Cells(1, 0).RowSpan = 2
        sheet.SheetCorner.Cells(1, 1).RowSpan = 2
        sheet.SheetCorner.Cells(1, 3).RowSpan = 2
        sheet.SheetCorner.Cells(1, 2).ForeColor = System.Drawing.Color.Red
        sheet.SheetCorner.Cells(2, 2).ForeColor = System.Drawing.Color.Green
    End Sub
End Class

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

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

<asp:Content ID="Content1" ContentPlaceHolderID="HeaderPlaceHolder1" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="#A0A0A0" BorderStyle="Solid"
        BorderWidth="1px">
        <CommandBar BackColor="#F6F6F6" ButtonFaceColor="Control" ButtonHighlightColor="ControlLightLight"
            ButtonShadowColor="ControlDark">
        </CommandBar>
        <Sheets>
            <FarPoint:SheetView SheetName="Sheet1">
            </FarPoint:SheetView>
        </Sheets>
    </FarPoint:FpSpread>
</asp:Content>