NegativeRedを有効にしてセル編集するとSetForeColor()で設定したフォント色が無効になる
対象製品
SPREAD for ASP.NET 8.0J
状況
修正済み
詳細
NegativeRedがTrueの状態でセル編集するとSetForeColor()で設定したフォント色が無効になる現象が発生します。
【再現手順】
1.新規WebフォームにSPREADを配置し、下記の再現コードを貼り付ける
2.プロジェクトを起動する
3.A1セルを編集する
4.Enterキーを押下してA1セルの編集を終了する
--- A1セルのフォント色が黒になる
--- SetForeColor()で設定した青になるのが正常な動作です
------------------------------------
Webフォームクラス
------------------------------------
Public Class WebForm1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then Return
FpSpread1.ActiveSheetView.ColumnCount = 5
FpSpread1.ActiveSheetView.Cells(0, 0, 0, 4).Value = 123
Dim cCell As New FarPoint.Web.Spread.CurrencyCellType()
cCell.NegativeRed = True
FpSpread1.ActiveSheetView.Columns(0).CellType = cCell
Dim iCell As New FarPoint.Web.Spread.IntegerCellType()
iCell.NegativeRed = True
FpSpread1.ActiveSheetView.Columns(1).CellType = iCell
Dim dCell As New FarPoint.Web.Spread.DoubleCellType()
dCell.NegativeRed = True
FpSpread1.ActiveSheetView.Columns(2).CellType = dCell
Dim pCell As New FarPoint.Web.Spread.PercentCellType()
pCell.NegativeRed = True
FpSpread1.ActiveSheetView.Columns(3).CellType = pCell
Dim gCell As New FarPoint.Web.Spread.GeneralCellType()
gCell.NegativeRed = True '
FpSpread1.ActiveSheetView.Columns(4).CellType = gCell
End Sub
End Class
【再現コード】
------------------------------------
クライアント側スクリプト
------------------------------------
document.onreadystatechange = function () {
if (document.readyState == "complete") {
var spread = document.getElementById("FpSpread1");
spread.Cells(0, 0).SetForeColor("blue");
spread.Cells(0, 1).SetForeColor("blue");
spread.Cells(0, 2).SetForeColor("blue");
spread.Cells(0, 3).SetForeColor("blue");
spread.Cells(0, 4).SetForeColor("blue");
}
}
【再現手順】
1.新規WebフォームにSPREADを配置し、下記の再現コードを貼り付ける
2.プロジェクトを起動する
3.A1セルを編集する
4.Enterキーを押下してA1セルの編集を終了する
--- A1セルのフォント色が黒になる
--- SetForeColor()で設定した青になるのが正常な動作です
------------------------------------
Webフォームクラス
------------------------------------
Public Class WebForm1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then Return
FpSpread1.ActiveSheetView.ColumnCount = 5
FpSpread1.ActiveSheetView.Cells(0, 0, 0, 4).Value = 123
Dim cCell As New FarPoint.Web.Spread.CurrencyCellType()
cCell.NegativeRed = True
FpSpread1.ActiveSheetView.Columns(0).CellType = cCell
Dim iCell As New FarPoint.Web.Spread.IntegerCellType()
iCell.NegativeRed = True
FpSpread1.ActiveSheetView.Columns(1).CellType = iCell
Dim dCell As New FarPoint.Web.Spread.DoubleCellType()
dCell.NegativeRed = True
FpSpread1.ActiveSheetView.Columns(2).CellType = dCell
Dim pCell As New FarPoint.Web.Spread.PercentCellType()
pCell.NegativeRed = True
FpSpread1.ActiveSheetView.Columns(3).CellType = pCell
Dim gCell As New FarPoint.Web.Spread.GeneralCellType()
gCell.NegativeRed = True '
FpSpread1.ActiveSheetView.Columns(4).CellType = gCell
End Sub
End Class
【再現コード】
------------------------------------
クライアント側スクリプト
------------------------------------
document.onreadystatechange = function () {
if (document.readyState == "complete") {
var spread = document.getElementById("FpSpread1");
spread.Cells(0, 0).SetForeColor("blue");
spread.Cells(0, 1).SetForeColor("blue");
spread.Cells(0, 2).SetForeColor("blue");
spread.Cells(0, 3).SetForeColor("blue");
spread.Cells(0, 4).SetForeColor("blue");
}
}
回避方法
Service Pack 3(v8.0.4004.2010)で修正済み。
Service Pack 3(v8.0.4004.2010)より前のバージョンでは次の回避方法が有効です。
------------------------------------------
下記のコードにあるようにセルの編集開始イベントをハンドルし、現象の回避コードを実装することで現象への対応が可能です。
【再現コードへの回避策適用例】
------------------------------------
クライアント側スクリプト
------------------------------------
document.onreadystatechange = function () {
if (document.readyState == "complete") {
var spread = document.getElementById("FpSpread1");
spread.Cells(0, 0).SetForeColor("blue");
spread.Cells(0, 1).SetForeColor("blue");
spread.Cells(0, 2).SetForeColor("blue");
spread.Cells(0, 3).SetForeColor("blue");
spread.Cells(0, 4).SetForeColor("blue");
//SPREADのセル編集開始イベントを使用します
if (spread.addEventListener) {
spread.addEventListener("EditStart", startSpreadEdit, false);
}
else {
spread.onEditStart = startSpreadEdit;
}
}
}
// セル編集開始時の処理
function startSpreadEdit(event) {
// フォント色設定が正常になるように処理を実行します
var spread = document.getElementById("FpSpread1");
var cell = event.cell;
var color = cell.GetForeColor();
if (cell.getAttribute("negativeRed") && (color != "red")) {
cell.setAttribute("savedColor", color);
}
}
Service Pack 3(v8.0.4004.2010)より前のバージョンでは次の回避方法が有効です。
------------------------------------------
下記のコードにあるようにセルの編集開始イベントをハンドルし、現象の回避コードを実装することで現象への対応が可能です。
【再現コードへの回避策適用例】
------------------------------------
クライアント側スクリプト
------------------------------------
document.onreadystatechange = function () {
if (document.readyState == "complete") {
var spread = document.getElementById("FpSpread1");
spread.Cells(0, 0).SetForeColor("blue");
spread.Cells(0, 1).SetForeColor("blue");
spread.Cells(0, 2).SetForeColor("blue");
spread.Cells(0, 3).SetForeColor("blue");
spread.Cells(0, 4).SetForeColor("blue");
//SPREADのセル編集開始イベントを使用します
if (spread.addEventListener) {
spread.addEventListener("EditStart", startSpreadEdit, false);
}
else {
spread.onEditStart = startSpreadEdit;
}
}
}
// セル編集開始時の処理
function startSpreadEdit(event) {
// フォント色設定が正常になるように処理を実行します
var spread = document.getElementById("FpSpread1");
var cell = event.cell;
var color = cell.GetForeColor();
if (cell.getAttribute("negativeRed") && (color != "red")) {
cell.setAttribute("savedColor", color);
}
}