Class Globals
Global functions for DB Addin
Inheritance
Namespace: DBaddin
Assembly: DBaddin.dll
Syntax
public class Globals
Methods
| Improve this Doc View SourcebalancedString(String, String, String, String)
returns the minimal bracket balancing string contained in theString, opening bracket defined in openBracket, closing bracket defined in closeBracket disregarding quoted areas inside optionally given quote character/string
Declaration
public static string balancedString(string theString, string openBracket, string closeBracket, string quote = "")
Parameters
Name | Description |
---|---|
theString | |
openBracket | |
closeBracket | |
quote |
Returns
Description |
---|
the balanced string |
Change(String, String, String, String)
changes theString to changedString by replacing substring starting AFTER keystr and ending with separator (so "(keystr)...;" will become "(keystr)(changedString);", case insensitive !!
Declaration
public static string Change(string theString, string keystr, string changedString, string separator)
Parameters
Name | Description |
---|---|
theString | |
keystr | |
changedString | |
separator |
Returns
Description |
---|
the changed string |
checkMultipleDBRangeNames(Range)
check if multiple (hidden, containing DBtarget or DBsource) DB Function names exist in theRange
Declaration
public static bool checkMultipleDBRangeNames(Range theRange)
Parameters
Name | Description |
---|---|
theRange |
Returns
Description |
---|
True if multiple names exist |
convertToBool(Object)
converts a passed object (reference, value) to a boolean
Declaration
public static bool convertToBool(object value)
Parameters
Name | Description |
---|---|
value | object to be converted |
Returns
Description |
---|
boolean result |
createFunctionsInCells(Range, ref Object)
creates functions in target cells (relative to referenceCell) as defined in ItemLineDef
Declaration
public static void createFunctionsInCells(Range originCell, ref object ItemLineDef)
Parameters
Name | Description |
---|---|
originCell | original reference Cell |
ItemLineDef | String array, pairwise containing relative cell addresses and the functions in those cells (= cell content) |
createListObject(Range)
create a ListObject one cell to the right of TargetCell and insert a dummy cmd sql definition for the list-object table (to be an external source)
Declaration
public static object createListObject(Range TargetCell)
Parameters
Name | Description |
---|---|
TargetCell | the reference cell for the ListObject (will be the source cell for the DBSetQuery function) |
Returns
Description |
---|
createPivotTable(Range)
create a pivot table object one cell below TargetCell and insert a dummy cmd sql definition for the pivot-cache external query
Declaration
public static void createPivotTable(Range TargetCell)
Parameters
Name | Description |
---|---|
TargetCell | the reference cell for the pivot table (will be the source cell for the DBSetQuery function) |
existsName(String)
helper function for check whether name exists in active workbook
Declaration
public static bool existsName(string CheckForName)
Parameters
Name | Description |
---|---|
CheckForName | name to be checked |
Returns
Description |
---|
true if name exists |
existsNameInSheet(ref String, Worksheet)
checks whether theName exists as a name in Worksheet theWs
Declaration
public static bool existsNameInSheet(ref string theName, Worksheet theWs)
Parameters
Name | Description |
---|---|
theName | |
theWs |
Returns
Description |
---|
true if it exists |
existsNameInWb(ref String, Workbook)
checks whether theName exists as a name in Workbook theWb
Declaration
public static bool existsNameInWb(ref string theName, Workbook theWb)
Parameters
Name | Description |
---|---|
theName | |
theWb |
Returns
Description |
---|
true if it exists |
existsSheet(ref String, Workbook)
checks whether worksheet called theName exists in workbook theWb
Declaration
public static bool existsSheet(ref string theName, Workbook theWb)
Parameters
Name | Description |
---|---|
theName | |
theWb |
Returns
Description |
---|
True if sheet exists |
fetchSubstr(String, String, String, Boolean)
fetches substring starting after keystr and ending with separator from theString, case insensitive !! if separator is "" then fetch to end of string
Declaration
public static string fetchSubstr(string theString, string keystr, string separator, bool includeKeyStr = false)
Parameters
Name | Description |
---|---|
theString | string to be searched |
keystr | string indicating the start of the substring combination |
separator | string ending the whole substring, not included in returned string! |
includeKeyStr | if includeKeyStr is set to true, include keystr in returned string |
Returns
Description |
---|
the fetched substring |
functionSplit(String, String, String, String, String, String)
splits theString into tokens delimited by delimiter, ignoring delimiters inside quotes and brackets
Declaration
public static object functionSplit(string theString, string delimiter, string quote, string startStr, string openBracket, string closeBracket)
Parameters
Name | Description |
---|---|
theString | string to be split into tokens, case insensitive ! |
delimiter | delimiter that string is to be split by |
quote | quote character where delimiters should be ignored inside |
startStr | part of theString where splitting should start after, case insensitive ! |
openBracket | opening bracket character |
closeBracket | closing bracket character |
Returns
Description |
---|
the list of tokens |
Remarks
theString is split starting from startStr up to the first balancing closing Bracket (as defined by openBracket and closeBracket) startStr, openBracket and closeBracket are case insensitive for comparing with theString. the tokens are not blank trimmed !!
getCustPropertyBool(String, Workbook)
get a boolean type custom property
Declaration
public static bool getCustPropertyBool(string name, Workbook Wb)
Parameters
Name | Description |
---|---|
name | name of the property |
Wb | workbook of the property |
Returns
Description |
---|
the value of the custom property |
getUnderlyingDBNameFromRange(Range)
gets underlying DBtarget/DBsource Name from theRange
Declaration
public static string getUnderlyingDBNameFromRange(Range theRange)
Parameters
Name | Description |
---|---|
theRange |
Returns
Description |
---|
the retrieved name |
refreshDBFuncLater()
"OnTime" event function to "escape" current (main) thread: event procedure to re-fetch DB functions results after triggering a recalculation inside Application.WorkbookBeforeSave
Declaration
public static void refreshDBFuncLater()
refreshDBFunctions(Workbook, Boolean)
recalculate fully the DB functions, if we have DBFuncs in the workbook somewhere
Declaration
public static void refreshDBFunctions(Workbook Wb, bool ignoreCalcMode = false)
Parameters
Name | Description |
---|---|
Wb | workbook to refresh DB Functions in |
ignoreCalcMode | when calling refreshDBFunctions time delayed (when saving a workbook and DBFC* is set), need to trigger calculation regardless of calculation mode being manual, otherwise data is not refreshed |
replaceDelimsWithSpecialSep(String, String, String, String, String, String)
replaces the delimiter (delimiter) inside theString with specialSep, regarding both quoted areas inside quote and bracketed areas (inside openBracket/closeBracket)
Declaration
public static string replaceDelimsWithSpecialSep(string theString, string delimiter, string quote, string openBracket, string closeBracket, string specialSep)
Parameters
Name | Description |
---|---|
theString | |
delimiter | |
quote | |
openBracket | |
closeBracket | |
specialSep |
Returns
Description |
---|
replaced string |
resolveConnstring(ref Object, ref String, Boolean)
create a final connection string from passed String or number (environment), as well as a EnvPrefix for showing the environment (or set ConnString)
Declaration
public static void resolveConnstring(ref object ConnString, ref string EnvPrefix, bool getConnStrForDBSet)
Parameters
Name | Description |
---|---|
ConnString | passed connection string or environment number, resolved (=returned) to actual connection string |
EnvPrefix | prefix for showing environment (ConnString set if no environment) |
getConnStrForDBSet |