ExcelManager--基于.Net的Excel读写管理类库(二)
ExcelManager类库的相关使用手册及源码,DLL文件都在这里
下面是此管理类库的接口类描述,以及相关源码文档使用手册等。
在仅使用时直接引用两个管理类(在DLL.rar包中)即可。
欢迎大家指点。。。

接口类
1
/**//* -----------------------------------------------------------------------
2
* 版权所有: 版权所有(C) 2006,EYE(Ver1.1)
3
* 文件编号: 0003
4
* 文件名称: IExcelManager.cs
5
* 系统编号: E-Eye_0001
6
* 系统名称: SFWL管理系统
7
* 模块编号: 0001
8
* 模块名称: Excel数据管理对象接口
9
* 设计文档:
10
* 完成日期: 2006-5-12 10:33:56
11
* 作 者: 林付国
12
* 内容摘要: 完成Excel数据管理对象API接口定义
13
* 属性描述: 该接口有10个属性
14
* 01 DataSource 数据源
15
* 02 Title Excel文件表格标题
16
* 03 FilePath 源文件路径
17
* 04 XMLFilePath XML架构文件路径
18
* 05 IsOpen 判断Excel管理对象是否已经打开
19
* 06 WriteType 写入类型(普通,重写,追加)
20
* 07 SheetName Sheet表名称
21
* 08 BackColor 背景颜色
22
* 09 ForeColor 字体颜色
23
* 10 Font 字体样式
24
* 方法描述: 该接口包括10个方法:
25
* 01 Open 打开Excel管理对象
26
* 02 Read 读取Excel文件中有效行列数据集
27
* 03 ReadCell 读取某单元格的内容
28
* 04 ReadCell 读取某单元格的内容,按行,列方式
29
* 05 Write 写入至Excel文件中
30
* 06 ReWrite 按照指定重写行重写数据
31
* 07 WriteCell 写数据至单元格
32
* 08 Close 资源释放
33
* 09 OpenCreate 打开Excel管理对象,若Excel文件不存在则创建之
34
* 10 ActiveSheet 激活当前读写数据的Sheet表
35
* 文件调用:无
36
* 约 束:1.执行导出机器上需要装有Office组件,且Excel文件版本在2000以上
37
* 2.Excel读文件目前仅支持单工作簿,单工作表读取
38
* 3.需读取Excel文件,在第一行必须依次存储二个范围,用于限定参数状态位,依次为:需要读取的起始单元格名称,结束单元格名称
39
* 4.需读取的每个Excel数据文件,必须有于之配对的同名XML架构文件(扩展项可支持不同文件名,不推荐此项)
40
* 5.写文件时,推荐先建立空Excel文件(扩展项可支持自动创建Excel文件,不推荐此项),本版本暂不提供数据插入功能
41
* 6.写入至Excel文件,提供(普通,Insert重写,Append追加)三种操作方式
42
* 数据量的大小要求单次写入:行1--60000以内,列1-255,Cell值长度1-255字符
43
* 目前写操作仅支持单工作簿,最大存在32个Sheet,每Sheet最大存储量为60000行
44
* 7.其它约束按照.Net框架及Microsoft Office Excel相关约定。
45
* -----------------------------------------------------------------------
46
* */
47
48
using System;
49
using System.Collections;
50
using System.Data;
51
52
namespace las.foundation.Interfaces
53

{
54
/**//// 类 编 号: 01
55
/// 类 名 称: IExcelManager
56
/// 内容摘要: Excel管理对象接口
57
/// 完成日期: 2006-5-12 14:36:51
58
/// 编码作者: 林付国
59
public interface IExcelManager : IDisposable
60
{
61
Property#region Property
62
/**//// <summary>
63
/// 数据源
64
/// </summary>
65
DataSet DataSource
{get;set;}
66
/**//// <summary>
67
/// Excel文件表格标题
68
/// </summary>
69
string Title
{get;set;}
70
/**//// <summary>
71
/// 源文件路径
72
/// </summary>
73
string FilePath
{get;set;}
74
/**//// <summary>
75
/// XML架构文件路径
76
/// </summary>
77
string XMLFilePath
{get;set;}
78
/**//// <summary>
79
/// 判断Excel管理对象是否已经打开
80
/// </summary>
81
/// <returns></returns>
82
bool IsOpen
{get;}
83
/**//// <summary>
84
/// Excel文件写入类型
85
/// </summary>
86
EnumType.WriteType WriteType
{get;set;}
87
/**//// <summary>
88
/// Sheet表名称
89
/// </summary>
90
string SheetName
{get;set;}
91
/**//// <summary>
92
/// 背景颜色
93
/// </summary>
94
System.Drawing.Color BackColor
{get;set;}
95
/**//// <summary>
96
/// 字体颜色
97
/// </summary>
98
System.Drawing.Color ForeColor
{get;set;}
99
/**//// <summary>
100
/// 字体样式
101
/// </summary>
102
System.Drawing.Font Font
{get;set;}
103
#endregion
104
105
Private Method#region Private Method
106
/**//// <summary>
107
/// 打开Excel管理对象
108
/// </summary>
109
/// <returns></returns>
110
bool Open();
111
/**//// <summary>
112
/// 读取Excel文件中有效行列数据集
113
/// </summary>
114
/// <returns></returns>
115
DataSet Read();
116
/**//// <summary>
117
/// 读取某单元格的内容
118
/// </summary>
119
/// <param name="strCell">单元格名称</param>
120
/// <returns></returns>
121
string ReadCell(string strCell);
122
/**//// <summary>
123
/// 读取某单元格内容,按行列参数方式
124
/// </summary>
125
/// <param name="iRow"></param>
126
/// <param name="iCol"></param>
127
/// <returns></returns>
128
string ReadCell(int iRow,int iCol);
129
/**//// <summary>
130
/// 写入数据集到Excel文件
131
/// </summary>
132
/// <returns></returns>
133
bool Write();
134
/**//// <summary>
135
/// 重写数据集到Excel文件,指定重写行
136
/// </summary>
137
/// <param name="iRow"></param>
138
/// <returns></returns>
139
bool ReWrite(int iRow);
140
/**//// <summary>
141
/// 写数据至单元格
142
/// </summary>
143
bool WriteCell(int iRow,int iCol,string strValue);
144
/**//// <summary>
145
/// 活动的Sheet表
146
/// </summary>
147
/// <param name="sheetindex"></param>
148
void ActiveSheet(EnumType.SheetIndex sheetindex);
149
/**//// <summary>
150
/// 资源释放
151
/// </summary>
152
void Close();
153
/**//// <summary>
154
/// 打开并创建此对象
155
/// </summary>
156
/// <returns></returns>
157
bool OpenCreate();
158
#endregion
159
}
160
}
161
在仅使用时直接引用两个管理类(在DLL.rar包中)即可。
欢迎大家指点。。。
1

/**//* -----------------------------------------------------------------------2
* 版权所有: 版权所有(C) 2006,EYE(Ver1.1)3
* 文件编号: 00034
* 文件名称: IExcelManager.cs5
* 系统编号: E-Eye_00016
* 系统名称: SFWL管理系统7
* 模块编号: 00018
* 模块名称: Excel数据管理对象接口9
* 设计文档: 10
* 完成日期: 2006-5-12 10:33:5611
* 作 者: 林付国12
* 内容摘要: 完成Excel数据管理对象API接口定义13
* 属性描述: 该接口有10个属性14
* 01 DataSource 数据源15
* 02 Title Excel文件表格标题16
* 03 FilePath 源文件路径17
* 04 XMLFilePath XML架构文件路径18
* 05 IsOpen 判断Excel管理对象是否已经打开19
* 06 WriteType 写入类型(普通,重写,追加)20
* 07 SheetName Sheet表名称21
* 08 BackColor 背景颜色22
* 09 ForeColor 字体颜色23
* 10 Font 字体样式24
* 方法描述: 该接口包括10个方法:25
* 01 Open 打开Excel管理对象26
* 02 Read 读取Excel文件中有效行列数据集27
* 03 ReadCell 读取某单元格的内容28
* 04 ReadCell 读取某单元格的内容,按行,列方式29
* 05 Write 写入至Excel文件中30
* 06 ReWrite 按照指定重写行重写数据31
* 07 WriteCell 写数据至单元格32
* 08 Close 资源释放33
* 09 OpenCreate 打开Excel管理对象,若Excel文件不存在则创建之34
* 10 ActiveSheet 激活当前读写数据的Sheet表35
* 文件调用:无36
* 约 束:1.执行导出机器上需要装有Office组件,且Excel文件版本在2000以上37
* 2.Excel读文件目前仅支持单工作簿,单工作表读取38
* 3.需读取Excel文件,在第一行必须依次存储二个范围,用于限定参数状态位,依次为:需要读取的起始单元格名称,结束单元格名称39
* 4.需读取的每个Excel数据文件,必须有于之配对的同名XML架构文件(扩展项可支持不同文件名,不推荐此项)40
* 5.写文件时,推荐先建立空Excel文件(扩展项可支持自动创建Excel文件,不推荐此项),本版本暂不提供数据插入功能41
* 6.写入至Excel文件,提供(普通,Insert重写,Append追加)三种操作方式42
* 数据量的大小要求单次写入:行1--60000以内,列1-255,Cell值长度1-255字符 43
* 目前写操作仅支持单工作簿,最大存在32个Sheet,每Sheet最大存储量为60000行44
* 7.其它约束按照.Net框架及Microsoft Office Excel相关约定。45
* -----------------------------------------------------------------------46
* */47

48
using System;49
using System.Collections;50
using System.Data;51

52
namespace las.foundation.Interfaces53


{54

/**//// 类 编 号: 0155
/// 类 名 称: IExcelManager56
/// 内容摘要: Excel管理对象接口57
/// 完成日期: 2006-5-12 14:36:5158
/// 编码作者: 林付国59
public interface IExcelManager : IDisposable60

{61

Property#region Property62

/**//// <summary>63
/// 数据源64
/// </summary>65

DataSet DataSource
{get;set;}66

/**//// <summary>67
/// Excel文件表格标题68
/// </summary>69

string Title
{get;set;}70

/**//// <summary>71
/// 源文件路径72
/// </summary>73

string FilePath
{get;set;}74

/**//// <summary>75
/// XML架构文件路径76
/// </summary>77

string XMLFilePath
{get;set;}78

/**//// <summary>79
/// 判断Excel管理对象是否已经打开80
/// </summary>81
/// <returns></returns>82

bool IsOpen
{get;}83

/**//// <summary>84
/// Excel文件写入类型85
/// </summary>86

EnumType.WriteType WriteType
{get;set;}87

/**//// <summary>88
/// Sheet表名称89
/// </summary>90

string SheetName
{get;set;}91

/**//// <summary>92
/// 背景颜色93
/// </summary>94

System.Drawing.Color BackColor
{get;set;}95

/**//// <summary>96
/// 字体颜色97
/// </summary>98

System.Drawing.Color ForeColor
{get;set;}99

/**//// <summary>100
/// 字体样式101
/// </summary>102

System.Drawing.Font Font
{get;set;}103
#endregion104

105

Private Method#region Private Method106

/**//// <summary>107
/// 打开Excel管理对象108
/// </summary>109
/// <returns></returns>110
bool Open();111

/**//// <summary>112
/// 读取Excel文件中有效行列数据集113
/// </summary>114
/// <returns></returns>115
DataSet Read();116

/**//// <summary>117
/// 读取某单元格的内容118
/// </summary>119
/// <param name="strCell">单元格名称</param>120
/// <returns></returns>121
string ReadCell(string strCell);122

/**//// <summary>123
/// 读取某单元格内容,按行列参数方式124
/// </summary>125
/// <param name="iRow"></param>126
/// <param name="iCol"></param>127
/// <returns></returns>128
string ReadCell(int iRow,int iCol);129

/**//// <summary>130
/// 写入数据集到Excel文件131
/// </summary>132
/// <returns></returns>133
bool Write();134

/**//// <summary>135
/// 重写数据集到Excel文件,指定重写行136
/// </summary>137
/// <param name="iRow"></param>138
/// <returns></returns>139
bool ReWrite(int iRow);140

/**//// <summary>141
/// 写数据至单元格142
/// </summary>143
bool WriteCell(int iRow,int iCol,string strValue);144

/**//// <summary>145
/// 活动的Sheet表146
/// </summary>147
/// <param name="sheetindex"></param>148
void ActiveSheet(EnumType.SheetIndex sheetindex);149

/**//// <summary>150
/// 资源释放151
/// </summary>152
void Close();153

/**//// <summary>154
/// 打开并创建此对象155
/// </summary>156
/// <returns></returns>157
bool OpenCreate();158
#endregion159
}160
}161

1.使用说明
word使用手册
相关DLL文件
2.所有源码
sourcecode1
sourcecode2
(可以下载了,下载后把文件解压到某一文件夹中即可)(传不上去文件,凌晨时传的非常好,现在修改后传不上去了,估计是我这网络问题,唉,算了,改天传吧)
好了,基本上需要用到的东东都已经发出来的,如果那里还有没说明白的地方,欢迎与我联系,共同探讨!![]()
另外,对JavaExcelAPI有研究的朋友,如有时间可以一起考虑将其转为.net版本的啊,毕竟有需求。
注:C#版本的JavaExcelAPI在SF上已被重构,感兴趣的朋友可去SF下载:
http://sourceforge.net/projects/nexcel
(以前未作细查,感谢精浪的提醒)
终于发完了,哇塞,快两点了,太晚了,偶要睡去了...![]()
![]()
![]()
浙公网安备 33010602011771号