|
ヘッダの非表示
行ヘッダまたは列ヘッダのVisibleプロパティをfalseに設定することで
ヘッダを非表示にすることができます。
このサンプルでは、行ヘッダを非表示に設定しています。
同様の手順で、列ヘッダを非表示にすることが可能です。
日付 | 曜日 | シフト | 出勤時間 | 退勤時間 | 休憩時間 | 実働時間 | 時間外 | 備考 |
2024/11/01 | 金 | S1 | 09:00 | 18:00 | 01:00 | 08:00 | | |
2024/11/02 | 土 | S1 | 09:00 | 18:00 | 01:00 | 08:00 | | |
2024/11/03 | 日 | 公休 | | | | | | |
2024/11/04 | 月 | S1 | 09:00 | 18:00 | 01:00 | 08:00 | | |
2024/11/05 | 火 | S1 | 09:00 | 18:00 | 01:00 | 08:00 | | |
2024/11/06 | 水 | S1 | 09:00 | 19:00 | 01:00 | 09:00 | 01:00 | 新店舗出店準備のため |
2024/11/07 | 木 | 公休 | | | | | | |
2024/11/08 | 金 | S1 | 09:00 | 19:30 | 01:00 | 09:30 | 01:30 | 新店舗出店準備のため |
2024/11/09 | 土 | S1 | | | | | | |
2024/11/10 | 日 | 公休 | | | | | | |
2024/11/11 | 月 | S1 | | | | | | |
2024/11/12 | 火 | S1 | | | | | | |
2024/11/13 | 水 | S1 | | | | | | |
2024/11/14 | 木 | 公休 | | | | | | |
2024/11/15 | 金 | S1 | | | | | | |
2024/11/16 | 土 | S1 | | | | | | |
2024/11/17 | 日 | 公休 | | | | | | |
2024/11/18 | 月 | S1 | | | | | | |
2024/11/19 | 火 | S1 | | | | | | |
2024/11/20 | 水 | S1 | | | | | | |
2024/11/21 | 木 | 公休 | | | | | | |
2024/11/22 | 金 | S1 | | | | | | |
2024/11/23 | 土 | S1 | | | | | | |
2024/11/24 | 日 | 公休 | | | | | | |
2024/11/25 | 月 | S1 | | | | | | |
2024/11/26 | 火 | S1 | | | | | | |
2024/11/27 | 水 | S1 | | | | | | |
2024/11/28 | 木 | 公休 | | | | | | |
2024/11/29 | 金 | S1 | | | | | | |
2024/11/30 | 土 | S1 | | | | | | |
|
ソースコード
別ウィンドウで表示
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>
|
|