/// 该方法可以快速将dataset写为Excel文件,免去Excel.dll支持
///摘要:采用ADO方式,把DataSet数据快速导出到Excel
///用法: 1) ExcelExporter xls = new ExcelExporter(DataSet); 2) xls.Export(excelFileName);
///作者:魏孙鼎
///
public class ExcelExporter
{
private DataSet dsSource = null;
private string provider = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 8.0;";
///
/// Constructor
///
/// 要导出的数据源
public ExcelExporter(DataSet ds)
{
dsSource = ds;
}
public bool Export(string fileName)
{
//前提判断
if (fileName == null || fileName == "")
return false;
if (!fileName.EndsWith(".xls"))
fileName += ".xls";
if (dsSource == null)
return false;