本帖最后由 lml5255485 于 2017-9-28 08:34 编辑
private void SaveBook(Action<C1XLBook> action)
{
var dlg = new SaveFileDialog();
dlg.Filter = "Excel Files (*.xlsx)|*.xlsx|Excel Files (*.xls)|*.xls";
if (dlg.ShowDialog() == true)
{
try
{
var book = new C1XLBook();
if (action != null)
{
action(book);
}
using (var stream = dlg.OpenFile())
{
book.Save(stream);
LHMessage.Show("导出Excel成功!", MessageBoxExecutionResults.Success);
}
}
catch
{
LHMessage.Show("导出Excel失败!", MessageBoxExecutionResults.Fail);
}
}
}
走到book.Save(stream);方法就会提示内存溢出,实际电脑内存还有不少 |