S2019 VB.NET升级到Spread for ASP.NET 10.0J 排序后,合计行不自动计算
代码如下:aspx页面:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm4.aspx.vb" Inherits="WebApplication1.WebForm4" %>
<%@ Register Assembly="FarPoint.Web.SpreadJ" Namespace="FarPoint.Web.Spread" TagPrefix="FarPoint" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="#A0A0A0" BorderStyle="Solid" BorderWidth="1px" Height="300" Width="600">
<CommandBar BackColor="#F6F6F6" ButtonFaceColor="Control" ButtonHighlightColor="ControlLightLight" ButtonShadowColor="ControlDark"></CommandBar>
<Sheets>
<FarPoint:SheetView SheetName="Sheet1"></FarPoint:SheetView>
</Sheets>
</FarPoint:FpSpread>
<asp:Button ID="Button1" runat="server" Text="Sort" />
</div>
</form>
</body>
</html>
后台代码:
Imports FarPoint.Web.Spread
Public Class WebForm4
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
FpSpread1.Sheets(0).RowCount = 6
FpSpread1.Sheets(0).Columns(0).Width = 150
FpSpread1.Sheets(0).Columns(2).Width = 200
FpSpread1.Sheets(0).Cells(0, 0).Value = 150
FpSpread1.Sheets(0).Cells(1, 0).Value = 510
FpSpread1.Sheets(0).Cells(2, 0).Value = 250
FpSpread1.Sheets(0).Cells(3, 0).Value = 50
FpSpread1.Sheets(0).Cells(4, 0).Value = 250
FpSpread1.Sheets(0).Cells(5, 0).Value = 290
FpSpread1.Sheets(0).AddRows(6, 1)
Dim Formula As String = "SUM(A1:A2)"
FpSpread1.Sheets(0).Cells(6, 0).Formula = Formula
FpSpread1.Sheets(0).Rows(6).BackColor = System.Drawing.Color.LightSkyBlue
FpSpread1.Sheets(0).SetText(6, 2, "第1-2行合计")
End If
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs)
FpSpread1.ActiveSheetView.AllowSort = True
' 排序做成
Dim sinfo As FarPoint.Web.Spread.SortInfo() = New FarPoint.Web.Spread.SortInfo(0) {}
sinfo(0) = New SortInfo(0, True)
FpSpread1.ActiveSheetView.SortRows(0, FpSpread1.ActiveSheetView.RowCount - 1, sinfo)
End Sub
End Class
画面效果:第七行单元格内容是"SUM(A1:A2)"
Sort按钮按下:第七行单元格内容没有变化
问题可以重现,SortRows会改变原有的行顺序,行顺序变了以后,这个公式单元格引用的单元格位置会发生变化。计算结果确实有问题。在最后的版本中也能重现。
由于webform版本目前已经停止维护,暂时没有什么好的解决方案,或者你也可以再和日本葡萄城确认一下日文版是否有其他的解决方案
如果项目条件允许,建议使用spreadjs替换spread webform ,这个产品目前在正常更新。也有日文资源包,可以显示日文文化和语言。
日文产品目前没有资源来提供问题验证。
建议通过日本葡萄城来获取技术支持
https://www.grapecity.co.jp/developer/support Richard.Ma 发表于 2023-7-19 18:16
日文产品目前没有资源来提供问题验证。
建议通过日本葡萄城来获取技术支持
我试了一下英文版的是一样的效果,不知道有啥解决的办法 孤月_2022 发表于 2023-7-20 15:52
我试了一下英文版的是一样的效果,不知道有啥解决的办法
方便的话,请上传一个重现问题的demo,我帮你看看有没有什么解决办法,
如果是产品的bug,可能比较难修复了,因为本身已经停止更新 Richard.Ma 发表于 2023-7-20 18:19
方便的话,请上传一个重现问题的demo,我帮你看看有没有什么解决办法,
如果是产品的bug,可能比较难 ...
英文版代码如下,效果和一楼的一样,我这demo上传不上去,只能贴代码了
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm4.aspx.vb" Inherits="WebApplication1.WebForm4" %>
<%@ Register Assembly="FarPoint.Web.Spread" Namespace="FarPoint.Web.Spread" TagPrefix="FarPoint" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="#A0A0A0" BorderStyle="Solid" BorderWidth="1px" Height="300" Width="600">
<CommandBar BackColor="#F6F6F6" ButtonFaceColor="Control" ButtonHighlightColor="ControlLightLight" ButtonShadowColor="ControlDark"></CommandBar>
<Sheets>
<FarPoint:SheetView SheetName="Sheet1"></FarPoint:SheetView>
</Sheets>
</FarPoint:FpSpread>
<asp:Button ID="Button1" runat="server" Text="Sort" />
</div>
</form>
</body>
</html>
后台代码:
Imports FarPoint.Web.Spread
Public Class WebForm4
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
FpSpread1.Sheets(0).RowCount = 6
FpSpread1.Sheets(0).Columns(0).Width = 150
FpSpread1.Sheets(0).Columns(2).Width = 200
FpSpread1.Sheets(0).Cells(0, 0).Value = 150
FpSpread1.Sheets(0).Cells(1, 0).Value = 510
FpSpread1.Sheets(0).Cells(2, 0).Value = 250
FpSpread1.Sheets(0).Cells(3, 0).Value = 50
FpSpread1.Sheets(0).Cells(4, 0).Value = 250
FpSpread1.Sheets(0).Cells(5, 0).Value = 290
FpSpread1.Sheets(0).AddRows(6, 1)
Dim Formula As String = "SUM(A1:A2)"
FpSpread1.Sheets(0).Cells(6, 0).Formula = Formula
FpSpread1.Sheets(0).Rows(6).BackColor = System.Drawing.Color.LightSkyBlue
FpSpread1.Sheets(0).SetText(6, 2, "第1-2行合计")
End If
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs)
FpSpread1.ActiveSheetView.AllowSort = True
' 排序做成
Dim sinfo As FarPoint.Web.Spread.SortInfo() = New FarPoint.Web.Spread.SortInfo(0) {}
sinfo(0) = New SortInfo(0, True)
FpSpread1.ActiveSheetView.SortRows(0, FpSpread1.ActiveSheetView.RowCount - 1, sinfo)
End Sub
End Class 收到,验证后给你回复 Richard.Ma 发表于 2023-7-21 18:44
收到,验证后给你回复
哈喽,老师,验证好了吗
你好,我在当前版本测试未发现你说的问题,建议升级版本看看
测试代码仅在空的spread上添加了这些代码
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
FpSpread1.ActiveSheetView.Cells(2, 2).Formula = "Sum(A1:A2)"
FpSpread1.ActiveSheetView.Cells(0, 0).Value = 12
FpSpread1.ActiveSheetView.Cells(1, 0).Value = 23
End Sub
不管是代码还是ui更新都是正常的 本帖最后由 孤月_2022 于 2023-7-25 09:56 编辑
Richard.Ma 发表于 2023-7-24 22:01
你好,我在当前版本测试未发现你说的问题,建议升级版本看看
测试代码仅在空的spread上添加了这些代码
你这个是写成固定的了吗,可以多写几行内容,sum前两行的数字,通过画面的按钮去排序Spread,再看sum的数字有没有变化
Protected Sub Button1_Click(sender As Object, e As EventArgs)
FpSpread1.ActiveSheetView.AllowSort = True
' 排序做成
Dim sinfo As FarPoint.Web.Spread.SortInfo() = New FarPoint.Web.Spread.SortInfo(0) {}
sinfo(0) = New SortInfo(0, True)
FpSpread1.ActiveSheetView.SortRows(0, FpSpread1.ActiveSheetView.RowCount - 1, sinfo)
End Sub
我是单独写了个按钮去排序,调用的还是spread的Sort功能,麻烦试一下我这种实现方法可以正常自动计算sum的值吗
页:
[1]
2