string strFileName = "";
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Excel 工作薄(.xls)|.xls";
saveFileDialog.FilterIndex = 0;
saveFileDialog.FileName = "在制品堆积表.xls";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
strFileName = saveFileDialog.FileName;
}
else
{
return;
}
if (File.Exists(strFileName))
{
try
{
File.Delete(strFileName);
}
catch (Exception)
{
MessageBox.Show("文件正在使用,请先关闭!", "系统提示");
return;
}
}
try
{
fpSpread1.SaveExcel(strFileName);
MessageBox.Show("导出成功!", "系统提示");
}
catch (Exception)
{
MessageBox.Show("导出失败,请重试!", "系统提示");
}