Excel Web Services Javascript API in embedded excel using excel mashup ( Asynchronous function calling inside a for loop) -
below embedded excel file using excelmashup [http://www.excelmashup.com/jsapi]. trying manupulate excel data using microsoft javascript api (jsom, ewa namespce object).
to view excel can save below code , use local server launch html.
![embedde excel view in browser][1]
i trying change value of a1 using loop change value of a18( a18 = a1+a2), there asynchronous function .getrangea1async('a1',inputcall,null);
but problem .getrangea1async not calling callback function inputcall. everytime inputcall taking value of =5;
if have idea problem or solution, appreciated. in advance.
i new @ javascript coding.
<div id="myexceldiv" style="width: 550px; height: 550px"></div> <script type="text/javascript" src="http://r.office.microsoft.com/r/rlidexcelwljs?v=1&kip=1"></script> <script type="text/javascript"> var filetoken = "sd3d1427d14bcfa9e8!126/4401186515721365992/t=0&s=0&v=!abnvwo79ftwffj4"; if (window.attachevent) { window.attachevent("onload", loadewaonpageload); } else { window.addeventlistener("domcontentloaded", loadewaonpageload, false); } function loadewaonpageload() { var props = { uioptions: { showgridlines: false, showrowcolumnheaders: false, showparameterstaskpane: false }, interactivityoptions: { allowtypingandformulaentry: true, allowparametermodification: true, allowsorting: false, allowfiltering: false, allowpivottableinteractivity: false } }; ewa.ewacontrol.loadewaasync(filetoken, "myexceldiv", props, null); } function getrangea1callback() { var i; var datawrite; var storedata; for(var i=0;i<5;i++) { ewa = ewa.ewacontrol.getinstances().getitem(0); datawrite=ewa.getactiveworkbook().getsheets().getitembyname('sheet1').getrangea1async('a1',inputcall,null); function inputcall(datawrite) { var range = datawrite.getreturnvalue(); values = new array(1); values[0] = new array(1); alert(i); values[0][0] = i; range.setvaluesasync(values,null,null); var dataread =ewa.getactiveworkbook().getsheets().getitembyname('sheet1').getrangea1async('a18', getrangevalues,null); function getrangevalues(dataread) { var dataread1 = dataread.getreturnvalue().getvaluesasync(0, storevalues); } function storevalues (dataread1) { storedata = dataread1.getreturnvalue(); } } } } </script> <input type="button" id="getrange" value="update charts" onclick="getrangea1callback()" />
Comments
Post a Comment