新建一个自己定义的类。如YFCExcel类
//报表类 YFC 2020.4.17日增加
/*
* 需要增加引用 system.management ,microsoft.office.interop.excel
using System.Data.OleDb;
using System.Collections;
using Excel = Microsoft.Office.Interop.Excel;
using System.Reflection;
using System.IO;
* */
public class YFCExcel
{
/// <summary>
/// 导出dbgridview到excel文件 ,string filepath, int RowCount/*需要导出的行数*/, int ColCount/*需要导出的列,从0开始*/, string[,] DataArray/*需要导出的数据*/,string[] StrTitle/*excel的标题*/
/// </summary>
/// <param name="filepath"></param>
public int exportToExcel(string filepath, int RowCount/*需要导出的行数*/, int ColCount/*需要导出的列,从0开始*/, string[,] DataArray/*需要导出的数据*/,string[] StrTitle/*excel的标题*/) //
{
//rec.Clear();
//re