/// <summary>
/// 将DataTable中的数据导出到Excel(支持Excel2003和Excel2007)
/// </summary>
/// <param name="dt"> DataTable</param>
/// <param name="url">Excel保存的路径DataTable</param>
/// <returns>导出成功返回True,否则返回false</ returns >
public bool ExportExcel(SysData.DataTable dt, string url)
{
bool falge = false;
Microsoft.Office.Interop.Excel.Application objExcel = null;
Workbook objWorkbook = null;
Worksheet objsheet = null;
try
{
//申明对象
objExcel = new Microsoft.Office.Interop.Excel.Application();
objWorkbook = objExcel.Workbooks.Add(Missing.Value);
objsheet = (Worksheet)objWorkbook.ActiveSheet;
//设置Excel不可见
objExcel.Visible
Datatable 导出Excel 到指定路径
最新推荐文章于 2023-02-17 13:26:14 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)