Michael Mandler
Posts: 34
Joined: 2014-03-26
|
Hello,
I'm having an issue with Add-in Express 8 and and XLL function's. I'm not sure if this change is by design or an issue with the current version.
Let's say I have a function defined like this
public static object GetTotalFundAssets(object[] funds, DateTime periodenddate, bool includeencumbrance = false,
bool includereportonly = false, int throughperiodno = 0)
{
}
If I provide a cell reference to the second parameter periodenddate, everything works properly. If I provide a date in the format of "3/31/14" (in quotes), the value will come into the function as 01/01/0001. In previous versions of add-in express this would come in as 3/31/14.
Is this a known change in the new version or a bug?
Thanks! |
|
Andrei Smolin
Add-in Express team
Posts: 18825
Joined: 2006-05-11
|
Hello Michael,
I suppose this is cased by some difference in the Regional Settings, see Control Panel | Region and Language | Formats | Additional settings | Date.
Andrei Smolin
Add-in Express Team Leader |
|
Michael Mandler
Posts: 34
Joined: 2014-03-26
|
Hi Andrei,
The date settings are correct and haven't changed. This is happening on all computers that have the version built with Add-in express 8. If I build the same Add-in with version 7 the date problem disappears. It's not an option for us to go back to version 7 though, as we need to support Office 2016. |
|
Andrei Smolin
Add-in Express team
Posts: 18825
Joined: 2006-05-11
|
Hello Michael,
I see. In Add-in Express 7, dates were handled by the standard marshaler provided by the .NET Framework. In case you enter a date incorrectly, e.g. when handling "3/31/14" on a non-English localization, this causes an exception which crashes Excel. In Add-in Express 8, we introduced a custom marshaler; when an exception occurs, the marshaler returns the minimal date. We will consider handling such strings in the next Add-in Express build but again, handling "3/31/14" on a non-English localization would return a localized equivalent of 01/01/0001. A correct workaround for you would be changing the parameter type from System.DateTime to System.Object and handling it depending on the actual data type passed to your function.
Andrei Smolin
Add-in Express Team Leader |
|
Michael Mandler
Posts: 34
Joined: 2014-03-26
|
Thanks for the information Andrei and considering making it work similar to how it did previously. |
|
Andrei Smolin
Add-in Express team
Posts: 18825
Joined: 2006-05-11
|
You are welcome.
Andrei Smolin
Add-in Express Team Leader |
|