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"));

}

}

加载模版

相关推荐
xiaofeichaichai33 分钟前
Webpack
前端·webpack·node.js
问心无愧05131 小时前
ctf show web入门111
android·前端·笔记
唐某人丶1 小时前
模型越来越强,我们还需要 Agent 工程吗?—— 从价值重估到 Harness 实践
前端·agent·ai编程
007张三丰1 小时前
软件测试专栏(11/20):测试框架开发:pytest深度解析与插件体系
运维·服务器·自动化测试·pytest·测试框架
智码看视界1 小时前
现代Web开发基础:全栈工程师的起航点
前端·后端·c5全栈
JS菌1 小时前
手写一个 AI Agent 全栈项目:从沙箱执行到子智能体的完整实现
前端·人工智能·后端
weixin_604236672 小时前
华三 路由器 极简核心配置
运维·服务器·网络·h3c·h3c路由器
鹤落晴春3 小时前
【Linux复习】管理SELinux安全性
linux·运维·服务器
excel3 小时前
HLS TS 文件损坏的元凶:Git 提交与拉取
前端