|
Posted by Rich on 02/04/06 04:31
In article <1139009106.661556.159080@g47g2000cwa.googlegroups.com>, UKuser
says...
>
>Hi Guys,
>
>I have a program which converts Excel spreadsheets to Javascript and
>allows interactivity. However it can't convert it to PHP, which is
>obviously better for users to view (in case J/S is turned off).
>
>How would I go about converting some of this created code (example JS
>below), or is there an easier way to get PHP to do the calculations
>itself? I am aware of an excel-server product but this is too expensive
>and doesnt actually produce any code.
>
>I'm not suggesting someone convert this (also as its only an example),
>but the code seems quite complicated for a junior PHP person. Any
>thoughts on what I could do?
>
>Thanks
>
>(code created by spreadsheet converter)
><script language="javascript">
>
>var co = new Object;
>function recalc_onclick(ctl) {
> if (true) {
>
>co.pA7D=eeparseFloat(document.formc.pA7D.value);calc(co);document.formc.pA7E.value=eedisplayFloat(co.pA7E);
>
>};};
>
>var eeisus=0;var eetrue="TRUE";var eefalse="FALSE";var eedec=".";var
>eeth=",";var eedecreg=new RegExp("[.]","g");var eethreg=new
>RegExp(",","g");
>
>var row1xD2D5=new Array(4);for(var jj=0;jj<4;jj++){row1xD2D5[jj]=0};var
>row1xE2E5=new Array(4);for(var
>jj=0;jj<4;jj++){row1xE2E5[jj]=0};function calc(data){var
>cA7D=data.pA7D;row1xD2D5[0]=(10);row1xE2E5[0]=(1);row1xD2D5[1]=(20);row1xE2E5[1]=(2);row1xD2D5[2]=(30);row1xE2E5[2]=(3);row1xD2D5[3]=(40);row1xE2E5[3]=(4);var
>cA7E=(lookup3vv((cA7D),row1xD2D5,0,3,row1xE2E5,0,3));data.pA7E=cA7E;};
>
>function myIsNaN(x){return(isNaN(x)||(typeof
>x=='number'&&!isFinite(x)));};function
>eeparseFloat(str){str=String(str).replace(eedecreg,".");var
>res=parseFloat(str);if(isNaN(res)){return 0;}else{return
>res;}};function eedisplayFloat(x){if(myIsNaN(x)){return
>Number.NaN;}else{return String(x).replace(/\./g,eedec);}};function
>lookup3vv(key,kvect,kfrom_start,kto_start,vvect,vfrom_,vto_){var
>current=0;var from_=kfrom_start;var
>to_=kto_start+1;while(true){current=(from_+to_)>>1;if(kvect[current]==key)break;if(from_==to_-1)break;if(kvect[current]<key){from_=current;}else{to_=current;}};while(current<kto_start){if(kvect[current]==kvect[current+1]){current++;}else{break;};};if(key<kvect[current])return
>Number.NaN;return vvect[vfrom_+current-kfrom_start]};
></script>
>
Doesn't look like there would be a direct conversion. The arrays and functions
used in Javascript are different than what you'd use in PHP. Javascript is also
processed on the client end while PHP is parsed on the server, so it depends on
where you need to do that at.
The Javascript probably allows access to the data in the spreadsheet, so you
might be dependent on Javascript either way to pull the data and send it to the
servers for your PHP code to process.
Rich
--
Newsguy Bandwidth Blowout Day! - Free Unlimited Downloads!
http://newsguy.com/nolimits.htm
[Back to original message]
|