找回密码
 立即注册

QQ登录

只需一步,快速开始

Clarencelee

注册会员

2

主题

8

帖子

32

积分

注册会员

积分
32
最新发帖
Clarencelee
注册会员   /  发表于:2021-8-11 13:18  /   查看:1918  /  回复:3
1金币
本帖最后由 Clarencelee 于 2021-8-11 13:20 编辑

image.png806066589.png

我把datagridview的值存到spread上
for (int row = 0; row < dgv.Rows.Count; row++)
            {
                for (int col = 0; col < dgv.Columns.Count; col++)
                    if(dgv.Rows[row].Cells[col].Value != null)
                        fpSpread1.Sheets[0].Cells[2+row, 0+col].Value = dgv.Rows[row].Cells[col].Value.ToString();

            }


然后提示
System.IndexOutOfRangeException
  HResult=0x80131508
  Message=无效的行索引:500(必须介于0和499)
  Source=FarPoint.Win.Spread
  StackTrace:
   在 FarPoint.Win.Spread.Cells.get_Item(Int32 row, Int32 column)
   在 ETFstandingbook.Form1.btnoutput_Click(Object sender, EventArgs e) 在 D:\source\repos\ETFstandingbook\ETFstandingbook\Form1.cs 中: 第 876 行
   在 System.Windows.Forms.Control.OnClick(EventArgs e)
   在 System.Windows.Forms.Button.OnClick(EventArgs e)
   在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   在 System.Windows.Forms.Control.WndProc(Message& m)
   在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
   在 System.Windows.Forms.Button.WndProc(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   在 System.Windows.Forms.Application.Run(Form mainForm)
   在 ETFstandingbook.Program.Main() 在 D:\source\repos\ETFstandingbook\ETFstandingbook\Program.cs 中: 第 19 行


3 个回复

倒序浏览
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2021-8-11 13:42:08
沙发
你给spread的sheet设置的行数是500,超出500行自然会报错

可以通过fpSpread1.ActiveSheet.RowCount来设置行数
回复 使用道具 举报
Clarencelee
注册会员   /  发表于:2021-8-11 15:37:33
板凳
Richard.Ma 发表于 2021-8-11 13:42
你给spread的sheet设置的行数是500,超出500行自然会报错

可以通过fpSpread1.ActiveSheet.RowCount来设 ...

好的,多谢
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2021-8-11 15:54:01
地板
不客气
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部