ポップアップヒント

セルノートの設定を行うことで、マウスカーソルをセル上に移動したときにツールチップが表示されます。 セルノートはセルのNoteプロパティで設定することができます。

このサンプルでは、前年比列の値に応じてそれぞれの行に表示するツールチップの中身を変更しています。
 製品ID製品分類製品名前年比4月5月6月7月8月9月
110001乳製品酪農ミルク
550050004500600055005000
220001清涼飲料水いよかんドリンク
100030002700270010003000
320002清涼飲料水ぶどうジュース
300035004800480030003500
420003清涼飲料水マンゴードリンク
20001000500105020001000
530001ビール激辛ビール
5500800085001000055008000
630002ビールモルトビール
300035002780400030003500
720004清涼飲料水ぶどうの街
500300200700500300
830003ビールオリエントの村
800095009580900080009500
940002焼酎吟醸 ほめごろし
600070009000950060007000
1040003焼酎大吟醸 オリエント
100050006000500010005000
   

ソースコード

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

public partial class rowcolcell_cellnote : 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;

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

    private void InitSpreadStyles(FarPoint.Web.Spread.SheetView sheet)
    {
        int i;

        // フォントサイズの設定
        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 = 140;
        sheet.Columns[3].Width = 40;
        sheet.Columns[4].Width = 65;
        sheet.Columns[5].Width = 65;
        sheet.Columns[6].Width = 65;
        sheet.Columns[7].Width = 65;
        sheet.Columns[8].Width = 65;
        sheet.Columns[9].Width = 65;

        sheet.Columns[3].HorizontalAlign = HorizontalAlign.Center;

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

        // セルノートの設定
        for (i = 0; i < sheet.RowCount; i++)
        {
            if (sheet.Cells[i, 3].Value.ToString() == "")
            {
                sheet.Cells[i, 0, i, sheet.ColumnCount - 1].Note = "売上が大きく増加しました";
            }
            else if (sheet.Cells[i, 3].Value.ToString() == "")
            {
                sheet.Cells[i, 0, i, sheet.ColumnCount - 1].Note = "売上が少し増加しました";
            }
            else if (sheet.Cells[i, 3].Value.ToString() == "")
            {
                sheet.Cells[i, 0, i, sheet.ColumnCount - 1].Note = "売上が少し減少しました";
            }
            else if (sheet.Cells[i, 3].Value.ToString() == "×")
            {
                sheet.Cells[i, 0, i, sheet.ColumnCount - 1].Note = "売上が大きく減少しました";
            }
        }

        // イメージ型セルの設定
        FarPoint.Web.Spread.ImageCellType icUp = new FarPoint.Web.Spread.ImageCellType();
        icUp.ImageUrl = "../images/uparrow.png";

        FarPoint.Web.Spread.ImageCellType icSmallUp = new FarPoint.Web.Spread.ImageCellType();
        icSmallUp.ImageUrl = "../images/smalluparrow.png";

        FarPoint.Web.Spread.ImageCellType icDown = new FarPoint.Web.Spread.ImageCellType();
        icDown.ImageUrl = "../images/downarrow.png";

        FarPoint.Web.Spread.ImageCellType icSmallDown = new FarPoint.Web.Spread.ImageCellType();
        icSmallDown.ImageUrl = "../images/smalldownarrow.png";

        for (i = 0; i < sheet.RowCount; i++)
        {
            if (sheet.Cells[i, 3].Value.ToString() == "")
            {
                sheet.Cells[i, 3].CellType = icUp;
            }
            else if (sheet.Cells[i, 3].Value.ToString() == "")
            {
                sheet.Cells[i, 3].CellType = icSmallUp;
            }
            else if (sheet.Cells[i, 3].Value.ToString() == "")
            {
                sheet.Cells[i, 3].CellType = icSmallDown;
            }
            else if (sheet.Cells[i, 3].Value.ToString() == "×")
            {
                sheet.Cells[i, 3].CellType = icDown;
            }

            sheet.Cells[i, 3].Value = "";
        }
    }
}

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

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

    Private Sub InitSpreadStyles(ByVal sheet As FarPoint.Web.Spread.SheetView)
        Dim i As Integer

        ' フォントサイズの設定
        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 = 140
        sheet.Columns(3).Width = 40
        sheet.Columns(4).Width = 65
        sheet.Columns(5).Width = 65
        sheet.Columns(6).Width = 65
        sheet.Columns(7).Width = 65
        sheet.Columns(8).Width = 65
        sheet.Columns(9).Width = 65

        sheet.Columns(3).HorizontalAlign = HorizontalAlign.Center

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

        ' セルノートの設定
        For i = 0 To sheet.RowCount - 1
            If sheet.Cells(i, 3).Value.ToString() = "" Then
                sheet.Cells(i, 0, i, sheet.ColumnCount - 1).Note = "売上が大きく増加しました"
            ElseIf sheet.Cells(i, 3).Value.ToString() = "" Then
                sheet.Cells(i, 0, i, sheet.ColumnCount - 1).Note = "売上が少し増加しました"
            ElseIf sheet.Cells(i, 3).Value.ToString() = "" Then
                sheet.Cells(i, 0, i, sheet.ColumnCount - 1).Note = "売上が少し減少しました"
            ElseIf sheet.Cells(i, 3).Value.ToString() = "×" Then
                sheet.Cells(i, 0, i, sheet.ColumnCount - 1).Note = "売上が大きく減少しました"
            End If
        Next

        ' イメージ型セルの設定
        Dim icUp As New FarPoint.Web.Spread.ImageCellType()
        icUp.ImageUrl = "../images/uparrow.png"

        Dim icSmallUp As New FarPoint.Web.Spread.ImageCellType()
        icSmallUp.ImageUrl = "../images/smalluparrow.png"

        Dim icDown As New FarPoint.Web.Spread.ImageCellType()
        icDown.ImageUrl = "../images/downarrow.png"

        Dim icSmallDown As New FarPoint.Web.Spread.ImageCellType()
        icSmallDown.ImageUrl = "../images/smalldownarrow.png"

        For i = 0 To sheet.RowCount - 1
            If sheet.Cells(i, 3).Value.ToString() = "" Then
                sheet.Cells(i, 3).CellType = icUp
            ElseIf sheet.Cells(i, 3).Value.ToString() = "" Then
                sheet.Cells(i, 3).CellType = icSmallUp
            ElseIf sheet.Cells(i, 3).Value.ToString() = "" Then
                sheet.Cells(i, 3).CellType = icSmallDown
            ElseIf sheet.Cells(i, 3).Value.ToString() = "×" Then
                sheet.Cells(i, 3).CellType = icDown
            End If

            sheet.Cells(i, 3).Value = ""
        Next
    End Sub
End Class

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

<%@ 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>