다음 코드로 Excel 추가 기능을 개발 중입니다. 나는 클래스 라이브러리를 생성하고 다음 코드Excel 추가 기능에서 작동
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace MyCustomAutomation
{
// Replace the Guid below with your own guid that
// you generate using Create GUID from the Tools menu
[Guid("5268ABE2-9B09-439d-BE97-2EA60E103EF6")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
public class MyFunctions
{
public MyFunctions()
{
}
public double MultiplyNTimes(double number1, double number2, double timesToMultiply)
{
double result = number1;
for (double i = 0; i < timesToMultiply; i++)
{
result = result * number2;
}
return result;
}
[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type type)
{
Registry.ClassesRoot.CreateSubKey(
GetSubKeyName(type, "Programmable"));
RegistryKey key = Registry.ClassesRoot.OpenSubKey(
GetSubKeyName(type, "InprocServer32"), true);
key.SetValue("",
System.Environment.SystemDirectory + @"\mscoree.dll",
RegistryValueKind.String);
}
[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type type)
{
Registry.ClassesRoot.DeleteSubKey(
GetSubKeyName(type, "Programmable"), false);
}
private static string GetSubKeyName(Type type,
string subKeyName)
{
System.Text.StringBuilder s =
new System.Text.StringBuilder();
s.Append(@"CLSID\{");
s.Append(type.GUID.ToString().ToUpper());
s.Append(@"}\");
s.Append(subKeyName);
return s.ToString();
}
}
}
나는 그것을 설치하고 기능이 엑셀 .I에서 잘 작동 내 문제는 내가 전화를 할 때한다는 것이다 value.However을 반환 MultiplyNTimes 기능을 사용할 수 있어요 추가 함수를 셀에서 호출하면 동일한 셀 자체에 결과가 표시되는 반면 호출 된 셀 이외의 다른 셀에서는 결과가 표시되기를 원합니다. 어떤 방향으로도 연결할 수 없으므로 완전히 단서가 없습니다. 도와주세요
그래서 당신은 결과를 원하는 않는 셀에 배치 할 수? –
수식이 A1로 작성 되었으면 답이 B1 또는 C1이되기를 원합니다. – Rohit
다른 셀을 수식으로 설정하면 Excel 사용자가 완전히 직관적입니다. 아마도 디자인을 재고해야합니다. –