30 lines
518 B
C#
30 lines
518 B
C#
|
using Application = Microsoft.Office.Interop.Excel.Application;
|
||
|
|
||
|
namespace ExcelAddIn.Tools;
|
||
|
|
||
|
public class Button2Tool : Tool
|
||
|
{
|
||
|
private readonly Application app;
|
||
|
public Button2Tool()
|
||
|
{
|
||
|
app = (Application)ExcelDnaUtil.Application;
|
||
|
}
|
||
|
public override void Execute()
|
||
|
{
|
||
|
if (app.ActiveCell == null)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
double? cellValue = app.ActiveCell.Cells.Value2;
|
||
|
if (cellValue != null)
|
||
|
{
|
||
|
app.ActiveCell.Cells.Value2 = ++cellValue;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
protected override void Dispose(bool disposing)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
}
|