|
接我上一篇C#導出Excel源碼. 网上反应比较强烈。本人也因为工作需要的原因,将其封装了成了ExcelManager。企业当中,做报表的数据来源肯定就是数据库了。该ExcelManager目前只提供Ms Sql Server的支持,因为我们公司使用的就是ms sql server 2000 了。封装后的ExcelManager,你只需传入你的报表表头(一级表头、二级表头。大部分有两级也就够了。如果你有多个,可自行修改该类.),并将对应的数据库表字段传入类库中的方法DeclareExcelApp即可。 同前一篇一样,你可将下面代码复制另存一个新类就可以了(不知为什么,我在家里上网老是传附件不上来!faint...)。随后,我会给出一个调用的方法的: namespace ExportToExcel { using System; using System.Data; using System.Data.SqlClient; using System.Windows.Forms; using System.Runtime.InteropServices;
/*********************************************************************************** ****Class Name : ExcelManger ****Author: KingNa ****Create Date : 2006-9-1 ****CopyRight: Reserve this info if you want to User this Class ***********************************************************************************/ public class ExcelManager:IDisposable { Excel.Range m_objRange = null; Excel.Application m_objExcel = null; Excel.Workbooks m_objBooks = null; Excel._Workbook m_objBook = null; Excel.Sheets m_objSheets = null; Excel._Worksheet m_objSheet = null; &n [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >> |