在互操作C#中延迟excel计算 [英] delaying excel calculations during interop C#

查看:121
本文介绍了在互操作C#中延迟excel计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须从C#程序中将数百个单元格输入到excel工作表中.每次我设置一个单元格或范围时,excel都会缓慢响应...大概是在我添加的每个输入之间更新各种输出.有没有一种方法可以禁用我的C#程序中的计算,并在设置完单元格并准备读取输出之后重新启用它?

I have to input several hundred cells into an excel sheet from a C# program. Each time I set a cell or a range, excel slowly responds... presumably updating various outputs between each input I add. Is there a way to disable calculations from my C# program, and re-enable it after I am done setting cells and ready to read the outputs?

推荐答案

是的,将Application.Calculation设置为xlCalculationManual,然后又返回到xlCalculationAutomatic.

Yes, set the Application.Calculation to xlCalculationManual, then back to xlCalculationAutomatic.

您还可以考虑将Application.ScreenUpdating设置为false,然后再返回到true.

You can also consider setting Application.ScreenUpdating to false and then back to true.

这篇关于在互操作C#中延迟excel计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆