c#mysql数据导出_C#数据库数据导入导出系列之二 数据库导出到Excel上

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Web;5 usingSystem.Web.UI.WebControls;6 usingSystem.Web.UI;7 usingSystem.Data;8 usingSystem.Text;9 usingSystem.Globalization;10 usingSystem.IO;11

12 namespaceVMS.Test.Classes13 {14 public classExcelHelper {15

16 #region Fields

17

18 string_fileName;19 DataTable _dataSource;20 string[] _titles = null;21 string[] _fields = null;22 int _maxRecords = 1000;23

24 #endregion

25

26 #region Properties

27

28 /**

29 ///限制输出到 Excel 的最大记录数。超出则抛出异常30 ///

31 public intMaxRecords {32 set { _maxRecords =value; }33 get { return_maxRecords; }34 }35

36 /**

37 ///输出到浏览器的 Excel 文件名38 ///

39 public stringFileName {40 set { _fileName =value; }41 get { return_fileName; }42 }43

44 #endregion

45

46 #region .ctor

47

48 /**

49 ///构造函数50 ///

51 /// 要输出到 Excel 的列标题的数组

52 /// 要输出到 Excel 的字段名称数组

53 /// 数据源

54 public ExcelHelper(string[] titles, string[] fields, DataTable dataSource): this(titles, dataSource) {55 if (fields == null || fields.Length == 0)56 throw new ArgumentNullException("fields");57

58 if (titles.Length !=fields.Length)59

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值