ReoGrid.NET集成到winfrom

ReoGrid一个支持excel操作的控件,支持集成到任何winfrom项目内。

先看效果图:

如何使用:

使用ReoGrid自带excel模版设计工具先设计一个模版,设计器如下:

具体例子看官方文档

代码示例如下:

var sheet = reoGridControl1.CurrentWorksheet;

SetReadOnly(sheet, new RangePosition("A1:AB2"));//设置只读

sheet.Rangessheet.Rows - num, 0, sheet.Rows, 24.BorderOutside = RangeBorderStyle.BlackBoldSolid;

sheet.Rangessheet.Rows - num, 0, sheet.Rows, 24.BorderInsideHorizontal = RangeBorderStyle.BlackSolid;

sheet.Rangessheet.Rows - num, 0, sheet.Rows, 24.BorderInsideVertical = RangeBorderStyle.BlackDotted;

增加边框

private void Sheet_CellDataChanged(object sender, unvell.ReoGrid.Events.CellEventArgs e)

{

var sheet = reoGridControl1.CurrentWorksheet;

int iid = Tools.ToInt(sheet.Cellse.Cell.Row, iidNum.Data, 0);

string state = sheet.Cellse.Cell.Row, stateNum.Data + "";

if (iid < 1 && string.IsNullOrEmpty(state))

{

sheete.Cell.Row, stateNum = "Add";

}

else if (iid > 0 && string.IsNullOrEmpty(state))

{

sheete.Cell.Row, stateNum = "Update";

}

}

public bool SetReadOnly(Worksheet sheet, RangePosition range)

{

sheet.IterateCells(range, ((row, col, cell) =>

{

cell.IsReadOnly = true;

return true;

}));

return true;

}

private void ReLoadGrid()

{

using (var ms = new System.IO.MemoryStream(Ufida.U8.Portal.ReportList.Properties.Resources.demo6))

{

reoGridControl1.Load(ms, unvell.ReoGrid.IO.FileFormat.ReoGridFormat);

var sheet1 = reoGridControl1.CurrentWorksheet;

sheet1.AfterCellEdit -= Sheet_CellDataChanged;

sheet1.AfterCellEdit += Sheet_CellDataChanged;

SetReadOnly(sheet1, new RangePosition("A1:AB2"));

}

}

加载模版

相关推荐
Flynt26 分钟前
AI 生成的界面,能放心点吗?我把 Google A2UI 的三层防线拆开测了一遍
前端·google·agent
前端混子1 小时前
我用 AI 做了个「禾月小历」,一套代码跑微信小程序和 H5
前端
IT_陈寒2 小时前
Java实战技巧总结:当你的finally块没有执行时会发生什么?
前端·人工智能·后端
小帅不太帅2 小时前
一年一次黑五,为了买软件真省钱,我做了个开源小站
前端·人工智能·github
JavaGuide4 小时前
刚刚,阿里版 Codex 上线了匿名模型 HungerG,无限 Token!
前端·后端
zhanlang02174 小时前
HTML 零基础入门到企业实战全套教程【第九章 9.3】移动端 HTML 基础适配入门
前端·html
用户69371750013844 小时前
AI 帮我写了大半年的代码,我却越来越不会写代码了
前端·后端·github
skywalk81634 小时前
把「假成功」赶出工具层:lightharness 两天升级复盘(4×5 模式矩阵 + 工具层 5 个缺陷)
开发语言·前端·人工智能·lightharness
彭亚川Allen5 小时前
从零手搓 RAG:用 Elasticsearch 存储与检索向量
前端·后端·面试
jerrywus5 小时前
15 个可以直接安装的 AI Agent Skills:按场景挑
前端·agent·claude