Can I call a spreadsheet function from a custom function in SpreadsheetGear -


i using spreadsheetgear , have been given spreadsheet vba macro need convert custom function (as ssg can't handle vba code). macro calls excel functions (match, index) , can't see how call these functions within custom function. ideas if possible , how it?

thanks

you can evaluate excel formula strings using isheet.evaluatevalue(...) method. example:

// a1:a3 on "sheet1" summed up. object val = workbook.worksheets["sheet1"].evaluatevalue("sum(a1:a3)");  // ensure numeric value if(val != null && val double) {     double sum = (double)val;     console.writeline(sum); } 

however, sounds using method inside custom function, should point out cannot use method sheet belongs workbook in iworkbookset being calculated. please review rules laid out in remarks section function.evaluate(...) method, pasted below, particularly ones bolded:


the implementation of method must follow number of rules:

  • the method must thread safe. versions of spreadsheetgear call method multiple threads @ same time.
  • the method must not use api in workbook set being calculated except iarguments.currentworksheet.name, iarguments.currentworksheet.index or iarguments.currentworksheet.workbook.name.
  • all access cells must through arguments.
  • accessing iarguments indexer has side effect of converting references ranges or arrays single simple value. use getarraydimensions , getarrayvalue access individual values of range or array. example, if first custom function argument range a1:c3, setting watch on arguments[0] in debugger convert range single simple value.
  • no references interfaces or objects passed to, or acquired during execution of method should used after method completes execution.

so if call isheet.evaluatevalue(...) within custom function, have done on sheet belongs iworkbookset other 1 being calculated. need done in thread-safe manner, per first rule mentioned above.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -