如何确定 C# 程序中可以创建的 Excel 工作表的最大数量?
我知道 Excel 工作表的唯一限制是系统资源,但我想知道是否有某种方法可以在 C# 中计算出该数字。
I know that the only limit on excel sheets is system resources, but I was wondering if there was some way I could figure out that number in C#.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里雷蒙德说:
这里他说:
话虽如此,不,您无法计算出受系统资源限制的数字。
相反,您必须继续添加另一张纸。当没有更多资源时,
.Add
调用将失败。Here Raymond says:
And here he says:
Having that said, no, you can't figure a number that is limited by system resources.
Instead you must go forward and add another sheet. When there are no more resources, the
.Add
call will fail.这取决于 Excel 工作表的大小、其中的数据、可用系统资源以及 Excel 和操作系统的版本。这绝对不是确定性的值。如果您确实认为必须这样做,请使用 try/catch 模式。只需继续创建 Excel 工作表,直到捕获异常,但我不建议这样做。
我认为您确实不需要同一个 Excel 工作表的多个实例。
如果您告诉我们更多细节,我们可以提供更多帮助。
It depends on the size of the Excel sheet, of the data in them, free system ressources and version of Excel and Operating System. It is definitely no deterministic value. If you really think you have to do it, use the try/catch pattern. Simply keep creating excel sheets until you catch an exception, but I wouldn't recommend this.
I don't think you really need more than one instance of one and the same Excel sheet.
we could help more if you tell us more details.