用Aspose.Cells.dll从Excel读取数据到DataSet
来源:互联网 发布:最近网络上很火的舞蹈 编辑:程序博客网 时间:2024/05/18 15:07
在项目中添加对 Aspose.Cells.dll的引用
/// <summary>
/// 获取Excel中的数据,根据Sheet名字获取数据/// </summary>
/// <param name="excelPath">文件路径</param>
/// <param name="sheetName">需要打开的sheet名称</param>
/// <returns></returns>
public static DataSet OpenExcelFile(string excelPath, string sheetName)
{
DataSet ds = new DataSet();
Workbook workBook = new Workbook(excelPath);
Worksheet workSheet = workBook.Worksheets[sheetName];
Cells cell = workSheet.Cells;
DataTable dt = new DataTable();
int count = cell.Columns.Count;
for (int i = 0; i < count; i++)
{
string str = cell.GetRow(0)[i].StringValue;
dt.Columns.Add(new DataColumn(str));
}
for (int i = 1; i < cell.Rows.Count; i++)
{
DataRow dr = dt.NewRow();
for (int j = 0; j < count; j++)
{
dr[j] = cell[i, j].StringValue;
}
dt.Rows.Add(dr);
}
dt.AcceptChanges();
ds.Tables.Add(dt);
return ds;
}
阅读全文
0 0
- 用Aspose.Cells.dll从Excel读取数据到DataSet
- 使用Aspose.Cells.dll导出数据到Excel
- c#使用aspose.cells 从datatable导出数据到excel
- c#使用aspose.cells 从datatable导出数据到excel
- Aspose.Cells读取excel文件
- MVC利用Aspose.Cells.dll实现Excel数据导入数据库
- Aspose.Cells 使用整理:读取Excel文件里的数据
- Aspose.Cells处理EXCEL数据
- 利用Aspose.Cells 组件导出数据到excel
- DataTable 用Aspose.Cells导出Excel
- 【学习笔记】C#使用Aspose.Cells.dll处理excel表格
- Aspose.Cells.dll 读写Excel的用法总结-技术&分享
- excel 在线预览类库:Aspose.Cells.dll
- Excel操作帮助类 (基于Aspose.Cells.dll)
- C# 读取Excel数据到DataSet
- 从DataSet导出数据到excel!!
- dataset读取excel中的数据到打dataset中
- Asp.Net中应用Aspose.Cells输出报表到Excel
- ≪统计学习精要(The Elements of Statistical Learning)≫课堂笔记(二)
- hdu 5982(16青岛现场赛)Relic Discovery水题
- UVALive
- hello world
- Maven学习总结
- 用Aspose.Cells.dll从Excel读取数据到DataSet
- 读写excel文件
- Hadoop学习笔记(二)HDFS
- 用可重用的链表模块来实现命令行菜单小程序V2.5
- MySQL优化必须调整的10项配置
- 快速解决vs2017应用C++ windows desktop application模板时中文乱码问题
- 链表的面试题(一)
- android 通过Banner实现 录播图的效果(和OkHttp3)结合
- 535. Encode and Decode TinyURL(C++)