ヘッダの非表示

行ヘッダまたは列ヘッダのVisibleプロパティをfalseに設定することで ヘッダを非表示にすることができます。

このサンプルでは、行ヘッダを非表示に設定しています。 同様の手順で、列ヘッダを非表示にすることが可能です。
日付曜日シフト出勤時間退勤時間休憩時間実働時間時間外備考
2021/02/01S109:0018:0001:0008:00  
2021/02/02S109:0018:0001:0008:00  
2021/02/03公休      
2021/02/04S109:0018:0001:0008:00  
2021/02/05S109:0018:0001:0008:00  
2021/02/06S109:0019:0001:0009:0001:00新店舗出店準備のため
2021/02/07公休      
2021/02/08S109:0019:3001:0009:3001:30新店舗出店準備のため
2021/02/09S1      
2021/02/10公休      
2021/02/11S1      
2021/02/12S1      
2021/02/13S1      
2021/02/14公休      
2021/02/15S1      
2021/02/16S1      
2021/02/17公休      
2021/02/18S1      
2021/02/19S1      
2021/02/20S1      
2021/02/21公休      
2021/02/22S1      
2021/02/23S1      
2021/02/24公休      
2021/02/25S1      
2021/02/26S1      
2021/02/27S1      
2021/02/28公休      

ソースコード

別ウィンドウで表示
using System;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;

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

        //データ設定
        setdata(FpSpread1.Sheets[0]);
        
        // SPREAD初期化
        InitSpread(FpSpread1.Sheets[0]);
    }

    private void InitSpread(FarPoint.Web.Spread.SheetView sheet)
    {
        // SPREAD設定
        FpSpread1.CommandBar.Visible = false;
        FpSpread1.CssClass = "spreadStyle";
        FpSpread1.UseClipboard = false;

        // フォントサイズの設定
        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.PageSize = sheet.RowCount;

        // 列幅の設定
        sheet.Columns[0].Width = 80;
        sheet.Columns[1].Width = 40;
        sheet.Columns[2].Width = 40;
        sheet.Columns[3].Width = 65;
        sheet.Columns[4].Width = 65;
        sheet.Columns[5].Width = 65;
        sheet.Columns[6].Width = 65;
        sheet.Columns[7].Width = 65;
        sheet.Columns[8].Width = 165;

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

        sheet.Columns[0, 7].HorizontalAlign = HorizontalAlign.Center;

        // ヘッダ        
        sheet.ColumnHeader.Cells[0, 0].Text = "日付";
        sheet.ColumnHeader.Cells[0, 1].Text = "曜日";
        sheet.ColumnHeader.Cells[0, 2].Text = "シフト";
        sheet.ColumnHeader.Cells[0, 3].Text = "出勤時間";
        sheet.ColumnHeader.Cells[0, 4].Text = "退勤時間";
        sheet.ColumnHeader.Cells[0, 5].Text = "休憩時間";
        sheet.ColumnHeader.Cells[0, 6].Text = "実働時間";
        sheet.ColumnHeader.Cells[0, 7].Text = "時間外";
        sheet.ColumnHeader.Cells[0, 8].Text = "備考";

        // 行ヘッダ非表示
        sheet.RowHeader.Visible = false;
    }

    private void setdata(FarPoint.Web.Spread.SheetView sheet) 
    {
        int year = DateTime.Now.Year;
        int month = DateTime.Now.Month;
        int days = DateTime.DaysInMonth(year, month);

        sheet.RowCount = days;
        sheet.ColumnCount = 9;

        for (int i = 1; i < days + 1; i++)
        {
            DateTime day = new DateTime(year,month,i);

            sheet.Cells[i - 1, 0].Value = day.ToString("yyyy/MM/dd");
            sheet.Cells[i - 1, 1].Value = day.ToString("ddd");
            if (i % 7 == 0 || i % 7 == 3)
            {
                sheet.Cells[i - 1, 2].Value = "公休";
            }
            else
            {
                sheet.Cells[i - 1, 2].Value = "S1";
            }

            if (day.ToString("ddd").Equals(""))
            {
                sheet.Rows[i - 1].BackColor = System.Drawing.Color.AliceBlue;
            }
            else if (day.ToString("ddd").Equals(""))
            {
                sheet.Rows[i - 1].BackColor = System.Drawing.Color.MistyRose;
            }

            // 出勤
            sheet.Cells[0, 3].Value = "09:00"; sheet.Cells[3, 3].Value = "09:00"; sheet.Cells[5, 3].Value = "09:00";
            sheet.Cells[1, 3].Value = "09:00"; sheet.Cells[4, 3].Value = "09:00"; sheet.Cells[7, 3].Value = "09:00";
            // 退勤
            sheet.Cells[0, 4].Value = "18:00"; sheet.Cells[3, 4].Value = "18:00"; sheet.Cells[5, 4].Value = "19:00";
            sheet.Cells[1, 4].Value = "18:00"; sheet.Cells[4, 4].Value = "18:00"; sheet.Cells[7, 4].Value = "19:30";
            // 休憩
            sheet.Cells[0, 5].Value = "01:00"; sheet.Cells[3, 5].Value = "01:00"; sheet.Cells[5, 5].Value = "01:00";
            sheet.Cells[1, 5].Value = "01:00"; sheet.Cells[4, 5].Value = "01:00"; sheet.Cells[7, 5].Value = "01:00";
            // 実働
            sheet.Cells[0, 6].Value = "08:00"; sheet.Cells[3, 6].Value = "08:00"; sheet.Cells[5, 6].Value = "09:00";
            sheet.Cells[1, 6].Value = "08:00"; sheet.Cells[4, 6].Value = "08:00"; sheet.Cells[7, 6].Value = "09:30";
            // 時間外
            sheet.Cells[0, 7].Value = ""; sheet.Cells[3, 7].Value = ""; sheet.Cells[5, 7].Value = "01:00";
            sheet.Cells[1, 7].Value = ""; sheet.Cells[4, 7].Value = ""; sheet.Cells[7, 7].Value = "01:30";
            // 備考
            sheet.Cells[0, 8].Value = ""; sheet.Cells[3, 8].Value = ""; sheet.Cells[5, 8].Value = "新店舗出店準備のため";
            sheet.Cells[1, 8].Value = ""; sheet.Cells[4, 8].Value = ""; sheet.Cells[7, 8].Value = "新店舗出店準備のため";
        }      
    }
}
Imports System
Imports System.Data
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.Configuration

Partial Public Class rowcolcell_headervisible
    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

        'データ設定
        setdata(FpSpread1.Sheets(0))

        ' SPREAD初期化
        InitSpread(FpSpread1.Sheets(0))
    End Sub

    Private Sub InitSpread(ByVal sheet As FarPoint.Web.Spread.SheetView)
        ' SPREAD設定
        FpSpread1.CommandBar.Visible = False
        FpSpread1.CssClass = "spreadStyle"
        FpSpread1.UseClipboard = False

        ' フォントサイズの設定
        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.PageSize = sheet.RowCount

        ' 列幅の設定
        sheet.Columns(0).Width = 80
        sheet.Columns(1).Width = 40
        sheet.Columns(2).Width = 40
        sheet.Columns(3).Width = 65
        sheet.Columns(4).Width = 65
        sheet.Columns(5).Width = 65
        sheet.Columns(6).Width = 65
        sheet.Columns(7).Width = 65
        sheet.Columns(8).Width = 165

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

        sheet.Columns(0, 7).HorizontalAlign = HorizontalAlign.Center

        ' ヘッダ        
        sheet.ColumnHeader.Cells(0, 0).Text = "日付"
        sheet.ColumnHeader.Cells(0, 1).Text = "曜日"
        sheet.ColumnHeader.Cells(0, 2).Text = "シフト"
        sheet.ColumnHeader.Cells(0, 3).Text = "出勤時間"
        sheet.ColumnHeader.Cells(0, 4).Text = "退勤時間"
        sheet.ColumnHeader.Cells(0, 5).Text = "休憩時間"
        sheet.ColumnHeader.Cells(0, 6).Text = "実働時間"
        sheet.ColumnHeader.Cells(0, 7).Text = "時間外"
        sheet.ColumnHeader.Cells(0, 8).Text = "備考"

        ' 行ヘッダ非表示
        sheet.RowHeader.Visible = False
    End Sub

    Private Sub setdata(ByVal sheet As FarPoint.Web.Spread.SheetView)
        Dim year As Integer = DateTime.Now.Year
        Dim month As Integer = DateTime.Now.Month
        Dim days As Integer = DateTime.DaysInMonth(year, month)

        sheet.RowCount = days
        sheet.ColumnCount = 9

        For i As Integer = 1 To days
            Dim day As New DateTime(year, month, i)

            sheet.Cells(i - 1, 0).Value = day.ToString("yyyy/MM/dd")
            sheet.Cells(i - 1, 1).Value = day.ToString("ddd")
            If i Mod 7 = 0 OrElse i Mod 7 = 3 Then
                sheet.Cells(i - 1, 2).Value = "公休"
            Else
                sheet.Cells(i - 1, 2).Value = "S1"
            End If

            If day.ToString("ddd").Equals("") Then
                sheet.Rows(i - 1).BackColor = System.Drawing.Color.AliceBlue
            ElseIf day.ToString("ddd").Equals("") Then
                sheet.Rows(i - 1).BackColor = System.Drawing.Color.MistyRose
            End If

            ' 出勤
            sheet.Cells(0, 3).Value = "09:00"
            sheet.Cells(3, 3).Value = "09:00"
            sheet.Cells(5, 3).Value = "09:00"
            sheet.Cells(1, 3).Value = "09:00"
            sheet.Cells(4, 3).Value = "09:00"
            sheet.Cells(7, 3).Value = "09:00"
            ' 退勤
            sheet.Cells(0, 4).Value = "18:00"
            sheet.Cells(3, 4).Value = "18:00"
            sheet.Cells(5, 4).Value = "19:00"
            sheet.Cells(1, 4).Value = "18:00"
            sheet.Cells(4, 4).Value = "18:00"
            sheet.Cells(7, 4).Value = "19:30"
            ' 休憩
            sheet.Cells(0, 5).Value = "01:00"
            sheet.Cells(3, 5).Value = "01:00"
            sheet.Cells(5, 5).Value = "01:00"
            sheet.Cells(1, 5).Value = "01:00"
            sheet.Cells(4, 5).Value = "01:00"
            sheet.Cells(7, 5).Value = "01:00"
            ' 実働
            sheet.Cells(0, 6).Value = "08:00"
            sheet.Cells(3, 6).Value = "08:00"
            sheet.Cells(5, 6).Value = "09:00"
            sheet.Cells(1, 6).Value = "08:00"
            sheet.Cells(4, 6).Value = "08:00"
            sheet.Cells(7, 6).Value = "09:30"
            ' 時間外
            sheet.Cells(0, 7).Value = ""
            sheet.Cells(3, 7).Value = ""
            sheet.Cells(5, 7).Value = "01:00"
            sheet.Cells(1, 7).Value = ""
            sheet.Cells(4, 7).Value = ""
            sheet.Cells(7, 7).Value = "01:30"
            ' 備考
            sheet.Cells(0, 8).Value = ""
            sheet.Cells(3, 8).Value = ""
            sheet.Cells(5, 8).Value = "新店舗出店準備のため"
            sheet.Cells(1, 8).Value = ""
            sheet.Cells(4, 8).Value = ""
            sheet.Cells(7, 8).Value = "新店舗出店準備のため"
        Next
    End Sub
End Class
<%@ Page MasterPageFile="~/MasterPage.master" Language="c#" AutoEventWireup="true" 
         Inherits="rowcolcell_headervisible" CodeFile="headervisible.aspx.cs" %>

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

<asp:Content ID="Content1" 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" />
        <Sheets>
            <farpoint:SheetView SheetName="Sheet1">
            </farpoint:SheetView>
        </Sheets>
    </farpoint:FpSpread>
</asp:Content>