【セル型】標準型/テキスト型セルに改行コードを含む文字列を設定した場合、MultilineをFalseに設定してもデータが複数行にわたって表示される
対象製品
SPREAD for .NET 2.5J Web Forms Edition
発生環境
動作保証環境と同様
状況
修正済み
詳細
標準型/テキスト型セルに改行コードを含む文字列を設定した場合、MultilineをFalseに設定してもデータが複数行にわたって表示されます
[再現手順]
1.新規WebフォームにSPREADのみを配置します
2.下記サンプルコードをコピーします
3.アプリケーションを実行します
4.A2/B2セルが複数行で表示されます
[サンプルコード]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
Return
End If
Dim gc As New FarPoint.Web.Spread.GeneralCellType
gc.AllowWrap = False
gc.Multiline = False
FpSpread1.Sheets(0).Cells(1, 0).CellType = gc
FpSpread1.Sheets(0).Cells(1, 0).Value = "長い日本語を" & System.Environment.NewLine & "折り返して表示する"
Dim tx As New FarPoint.Web.Spread.TextCellType
tx.AllowWrap = False
tx.Multiline = False
FpSpread1.Sheets(0).Cells(1, 1).CellType = tx
FpSpread1.Sheets(0).Cells(1, 1).Value = "長い日本語を" & System.Environment.NewLine & "折り返して表示する"
FpSpread1.Sheets(0).Columns(0, 1).Width *= 2
FpSpread1.Sheets(0).Rows(1).Height *= 2
End Sub
[再現手順]
1.新規WebフォームにSPREADのみを配置します
2.下記サンプルコードをコピーします
3.アプリケーションを実行します
4.A2/B2セルが複数行で表示されます
[サンプルコード]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
Return
End If
Dim gc As New FarPoint.Web.Spread.GeneralCellType
gc.AllowWrap = False
gc.Multiline = False
FpSpread1.Sheets(0).Cells(1, 0).CellType = gc
FpSpread1.Sheets(0).Cells(1, 0).Value = "長い日本語を" & System.Environment.NewLine & "折り返して表示する"
Dim tx As New FarPoint.Web.Spread.TextCellType
tx.AllowWrap = False
tx.Multiline = False
FpSpread1.Sheets(0).Cells(1, 1).CellType = tx
FpSpread1.Sheets(0).Cells(1, 1).Value = "長い日本語を" & System.Environment.NewLine & "折り返して表示する"
FpSpread1.Sheets(0).Columns(0, 1).Width *= 2
FpSpread1.Sheets(0).Rows(1).Height *= 2
End Sub
回避方法
2007/09/05版で修正済み。
2007/09/05版より前のバージョンでは次の回避方法が有効です。
下記のような独自のセル型クラスを作成することで回避することができます。
------------------------------------
Webフォームクラス
------------------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
Return
End If
Dim tx As New MyText
tx.AllowWrap = False
tx.Multiline = False
FpSpread1.Sheets(0).Cells(1, 1).CellType = tx
FpSpread1.Sheets(0).Cells(1, 1).Value = "長い日本語を" & System.Environment.NewLine & "折り返して表示する"
FpSpread1.Sheets(0).Columns(0, 1).Width *= 2
FpSpread1.Sheets(0).Rows(1).Height *= 2
End Sub
------------------------------------
カスタムセル型クラス
------------------------------------
<Serializable()> Public Class MyText
Inherits FarPoint.Web.Spread.TextCellType
Implements FarPoint.Web.Spread.Model.ICanSerializeXml
Public Overrides Function PaintCell(ByVal id As String, ByVal parent As System.Web.UI.WebControls.TableCell, ByVal style As FarPoint.Web.Spread.Appearance, ByVal margin As FarPoint.Web.Spread.Inset, ByVal value As Object, ByVal upperLevel As Boolean) As System.Web.UI.Control
If Not Me.AllowWrap AndAlso Not Me.Multiline Then
value = Convert.ToString(value).Replace(ControlChars.CrLf, "")
End If
Return MyBase.PaintCell(id, parent, style, margin, value, upperLevel)
End Function
Public ReadOnly Property CanSerializeXml() As Boolean Implements FarPoint.Web.Spread.Model.ICanSerializeXml.CanSerializeXml
Get
Return False
End Get
End Property
End Class
2007/09/05版より前のバージョンでは次の回避方法が有効です。
下記のような独自のセル型クラスを作成することで回避することができます。
------------------------------------
Webフォームクラス
------------------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
Return
End If
Dim tx As New MyText
tx.AllowWrap = False
tx.Multiline = False
FpSpread1.Sheets(0).Cells(1, 1).CellType = tx
FpSpread1.Sheets(0).Cells(1, 1).Value = "長い日本語を" & System.Environment.NewLine & "折り返して表示する"
FpSpread1.Sheets(0).Columns(0, 1).Width *= 2
FpSpread1.Sheets(0).Rows(1).Height *= 2
End Sub
------------------------------------
カスタムセル型クラス
------------------------------------
<Serializable()> Public Class MyText
Inherits FarPoint.Web.Spread.TextCellType
Implements FarPoint.Web.Spread.Model.ICanSerializeXml
Public Overrides Function PaintCell(ByVal id As String, ByVal parent As System.Web.UI.WebControls.TableCell, ByVal style As FarPoint.Web.Spread.Appearance, ByVal margin As FarPoint.Web.Spread.Inset, ByVal value As Object, ByVal upperLevel As Boolean) As System.Web.UI.Control
If Not Me.AllowWrap AndAlso Not Me.Multiline Then
value = Convert.ToString(value).Replace(ControlChars.CrLf, "")
End If
Return MyBase.PaintCell(id, parent, style, margin, value, upperLevel)
End Function
Public ReadOnly Property CanSerializeXml() As Boolean Implements FarPoint.Web.Spread.Model.ICanSerializeXml.CanSerializeXml
Get
Return False
End Get
End Property
End Class
キーワード
SPRN05892
この文書は、以前は次のバグレポートIDで公開されていました : 6983