C # Technique - getting constant values ​​per row

Is there a good way to convert strings like "xlSum", "xlAverage" and "xlCount" to the value that they have in Microsoft.Office.Interop.Excel.XlConsolidationFunction?

I think the reflection will be slow (if possible). There are about 10 of these constant values. I tried, if possible, to avoid the large switch statement.

+3
source share
2 answers

This listing is for you to use.

using Microsoft.Office.Interop.Excel;

XlConslidationFunction func = (XlConsolidationFunction)
                               Enum.Parse( typeof(XlConsolidationFunction),
                                           stringVal );
+5
source

Instead of a switch, you can always use Dictionary<string, ...>and fill it once when the application starts

0
source

All Articles