C# excel互操作公式拖动
我正在使用 C# excel 互操作框架自动为我的公司生成一堆报告,我想知道是否有人知道如何用它来拖拽方程。
如果我可以使用命名范围来做到这一点,那就更好了,但即使我必须对行进行硬编码,以便沿着将 A10:J10 向下拖动到 A20:J20 的线,这也可能没问题。
即使是任何指向解释如何执行此操作的网页的指针也将不胜感激,因为我有点陷入这个困境。
谢谢!
I'm using the C# excel interop framework to automating generate a bunch of reports for my company and I'm wondering if anyone knows how to do equation dragging with this.
If I could do this with a named range this would be even better, but even if I have to hard code the rows so it's along the lines of drag A10:J10 down to A20:J20 this would probably be ok.
Even any pointers to a webpage explaining how to do this would be much appreciated as I'm kind of stuck on this one.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Range 对象有一个名为 AutoFill 的方法,您应该尝试一下。
Range object has a method called AutoFill, you should try that.
您可以使用下一个片段。希望有帮助
You can use the next snippet. Hope be helpful
不久前我做了类似的事情。这是我的代码的示例:
公式是相对应用的。我为每个步骤使用了单独的变量,这样它们就可以被
Dispose
。让我知道这是否有帮助。I did something like this not that long ago. Here's an example of my code:
The formula is applied relatively. And I used separate variables for each step so they can be
Disposed
. Let me know if this helps.您可以通过调用 ListObjects Worksheet 对象的集合。这相当于在 Excel 中使用“格式化为表格”命令。在表行中输入的任何方程都将使用对表列的相对引用自动填充到表的所有行。此行为默认情况下处于启用状态,但可以通过以下设置进行控制
You can create an Excel table (ListObject) by invoking the Add method of the ListObjects collection of the Worksheet object. This is the equivalent of using the "Format as table" command in Excel. Any equation entered in a table row will auto-fill to all rows of the table using relative references to table columns. This behavior is on by default but can be controlled by the setting at