This sample add-in shows how to trap the OnCalculate event, which occurs just after a sheet has finished calculating.
It also demonstrates the use of CXlOper to manipulate cell references.
The sample displays the following features:
The processing at the end of the function CTextFileTask::PopulateDestination is very important.
// Get the current contents of the destination range xloOldValue.Coerce(m_xloDest); // Compare the current value with the contents of the file // and update the destination range ONLY if they are different. if (xloOldValue != xloValue) m_xloDest.SetValue(xloValue);
We look at the current contents of the destination range, and compare them to the values we intend to put there. If they are identical then we do not update the range.
Every time we update a cell, we can cause the sheet to be calculated. Since this method is called during OnCalculate, we might go into an endless loop, which is to be avoided.
By making sure that we only update the cells when necessary, we only cause a finite number of cascading calculations.
If you are using MS Developer Studio 6, then you should open the project file CalcEvt.dsp.
If you are using MS Visual Studio .NET 2002, then you should open the solution file CalcEvt.sln or the project file CalcEvt.vcproj.
If you are using MS Visual Studio .NET 2003, then you should open the solution file CalcEvt71.sln or the project file CalcEvt71.vcproj.
If you are using MS Visual Studio 2005, then you should open the solution file CalcEvt8.sln or the project file CalcEvt8.vcproj.