//打开Excel,并返回第一张sheet表数据
private DataTable Open_Excel()
{
DataTable dt = new DataTable();
OpenFileDialog pOpenFileDialog = new OpenFileDialog();
pOpenFileDialog.Filter = “Excel Files|.xls|Excel Files|.xlsx”;
pOpenFileDialog.Multiselect = false;
pOpenFileDialog.Title = “打开文件”;
if (pOpenFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string path = pOpenFileDialog.FileName;
dt = get_dt_sqh(path);
}
return dt;
}
//保存为Excel
private bool Out_Excel(DataTable dt,string sheetName)
{
bool flag = false;
string filePath = “”;
if (dt == null)
{
flag = false;
}
else
{
try
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{