Excel-DNA / Excel-DNA/ExcelDna

RTD functions are recalculated on cut+paste any cell in a sheet

Open
#209 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.5k
Forks
292
Avg merge
20d 12h
Merged PRs (30d)
1

Description

Using ExcelAsyncUtil.Observe will cause the function (and all dependencies) to be recalculated whenever cut+paste any cell in the spreadsheet. This can be annoying when you have many dependencies. It will be much appreciated if it can be fixed.

To reproduce:
1.Set A1=CreateHandle("abc")
2.Set A2=LastChanged(A1)
3.Ctrl+X in B2
4.CTRL+V in B3
5.Notice A2 is changed although the function inputs are not changed.

[ExcelFunction( Name = "LastChanged" )]
public static object LastChanged( [ExcelArgument] object param )
{
return DateTime.Now.ToLongTimeString();
}

[ExcelFunction( Name = "CreateHandle" )]
public static object CreateHandle( [ExcelArgument] object param )
{
var result = ExcelAsyncUtil.Observe( "CreateHandle", new[] {param}, () =>
{
var handle = new Handle( param?.ToString() );

return handle;
} );

return result;
}

public class Handle : IExcelObservable, IDisposable
{
private IExcelObserver observer;

public Handle( string name )
{
Name = name;
}

public string Name { get; set; }

public IDisposable Subscribe( IExcelObserver pObserver )
{
observer = pObserver;
observer.OnNext( Name );
return this;
}

public void Completed()
{
observer.OnCompleted();
}

public void Dispose()
{
//storage.Remove( this );
}
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.