This add-in uses the CXlApp::GetInternational function to get the current list separator. It then inserts a formula into a cell, using the correct separator.
In English the formula is =MyFunc(101,99). In German the formula will be =MyFunc(101;99).
BOOL PasteFormulaIntl() { XLL_FIX_STATE; //}}XLP_SRC CXlOper xloListSep, xloActive; char achFormula[256]; if (CXllApp::GetInternational(XlInternationalListSeparator, xloListSep)) { // Print the formula using the current separator // e.g.: "=MyFunc(101,99)" in English // or "=MyFunc(101;99)" in German _snprintf(achFormula, sizeof(achFormula), "=MyFunc(%.0f%s%.0f)", 101.0,(LPCSTR)xloListSep.ToString(), 99.0); if (xloActive.GetActiveCell() && xloActive.SetFormula(achFormula)) return TRUE; } return FALSE; }
You may need to use a similar technique for number formats etc.
The simple worksheet function GetInternational() also calls CXlApp::GetInternational() and returns the value found. Note that the add-in function is marked as "Defer recalculation". CXllApp::GetInternational() will always fail if called from worksheet functions that have not been marked as "Defer recalculation".
Note also that the add-in function is marked as "Volatile". This causes the formula to be automatically recalculated whenever Excel recalculates the current sheet. Under most versions of Windows and Excel, Excel recalculates whenever the user changes the regional settings, so the formula will update automatically.
See the workbook International.xls for examples of the add-in function in use.
CXllApp::GetInternational |
CXlOper::GetActiveCell |
CXlOper::SetFormula |
If you are using MS Developer Studio 6, then you should open the project file International.dsp.
If you are using MS Visual Studio .NET 2002, then you should open the solution file International.sln or the project file International.vcproj.
If you are using MS Visual Studio .NET 2003, then you should open the solution file International71.sln or the project file International71.vcproj.
If you are using MS Visual Studio 2005, then you should open the solution file International8.sln or the project file International8.vcproj.