Can Range.Value2 & Range.Formula have different values in C#, not VBA?

眉间皱痕 提交于 2019-12-08 04:30:21

问题


I want to create a UDF which is like GetPath(parameter), where parameter can be a cell reference like "B1", or a string what the GetPath does, based on input, it will call web service to get path for input e.g. formula of cell A1=GetPath(B1), cell B1 has some string, the function should return path and put it in cell A1, i.e. "Value2" of A1 should be path of B1.

Now in C#, when I did sth FormulaCell.Value2 = path, its formula changes, too but I want "Formula" & "Value2" to be different.

I know this is possible in VBA, but I am using C#.

Anyone knows how to accomplish this?

thanks

I googled, googled and still not found a solution. This sounds like a basic feature but impossible in C#. at least that's what I got through research. I am sure some of you have encountered the same issue before, just wonder how you work it out?

I am going to try this in VB.NET if that works then I will reference it in C#. If anyone knows in VB.NET, pls also post. thanks


回答1:


My addin was COM AddIn which is not possible to have range.value2 different from range.formula no matter it is C# or VB.NET.

This can be done using VBA, Automation AddIn in .NET, or xll addin. For xll addin, you can either write in C/C++, or use existing tools like ExcelDNA, managedXLL, XLW, etc.



来源:https://stackoverflow.com/questions/6023012/can-range-value2-range-formula-have-different-values-in-c-not-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!