开发者

Syncfusion XlsIO - Unexpected token exception

开发者 https://www.devze.com 2022-12-17 11:51 出处:网络
We have a Syncfusion GridControl that contains formulae like: IF(R2<>0,100*(R3-R2)/R2,0) These formulae work fine in the grid and the formulae calculation engine gives the correct results whatever

We have a Syncfusion GridControl that contains formulae like: IF(R2<>0,100*(R3-R2)/R2,0)

These formulae work fine in the grid and the formulae calculation engine gives the correct results whatever regional settings/number formats we have on the PC concerned (e.g. English, French, Hungarian).

They also work perfectly when we use the XlsIO GridtoExcel function to create Excel files under English regional settings.

However, we get errors of the type below when we attempt to use GridtoExcel under regional settings like French and Hungarian that use a semi-colon argument separator in Excel:

Unexpected token.Unexpected token type: tNumber, string value: ,0 at position 24. Formula: IF(R2<>0,100*(R3-R2)/R2,0), Position: 26

We have tried to use the SetSeparators function, but it has no effect (as recommended in the KB article)

Any ideas on开发者_运维技巧 the correct approach here? Unfortunately the documentation on SetSeparators isn't too helpful here.

Many thanks

Richard


The SetSeparators() method was set for WorkBook alone. For Grid, you can specify the separators in GridFormulaEngine. The GridFormulaEngine considers the culture ‘en-US’ as a default culture. For the other cultures, the ParseDecimalSeparator and ParseArgumentSeparator properties have to be set explicitly along with the SetSeparators() method. Here is the code,

 GridFormulaEngine.ParseDecimalSeparator = char.Parse(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);

 GridFormulaEngine.ParseArgumentSeparator = char.Parse(CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator);

Regards, Christo.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号