1、命名空间
using DevExpress.XtraEditors;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;
using System;
using System.Data;
using System.Windows.Forms;
using Microsoft.Office.Interop.Excel;
using System.IO;
using System.Drawing;
2、代码
public class ImportExcels
{
/// <summary>
/// 导入
/// </summary>
/// <param name="grvData"></param>
/// <param name="grvView"></param>
public void Import(GridControl grvData, GridView grvView)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Excel文件";
ofd.FileName = "";
ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
ofd.Filter = "所有文件(*.*)|*.*|Excel2003文件(*.xls)|*.xls|Excel2007文件(*.xlsx)|*.xlsx";
ofd.ValidateNames = true;
ofd.CheckFileExists = t