Jump to content

PHP to excel spreadsheet help


patto

Recommended Posts

I have recently got a webpage PHP script and i am wanting the calculator that the script runs into an excell spreadsheet or a program can anyone offer any advice or what programs to use and/or what to do.

THanx patto
Link to comment
Share on other sites

Sorry, lol new to this dont really know what to say

Ok i have been using a website for a special calculator which gives you answers to catenary curves and i have emailed them asking for a copy for personal use and they have sent me the PHP scripted webpage and what i want to do is chage it from a webpage to a microsoft excel spreadsheet or somehow use the page they have sent me and set it up so the calculator works without the internet.

i hope this makes more sense

i believe this is the scripting that amkes the calculator works


0)) $F = $_GET['F']; else $F = 0.674427074; if (isset($_GET['g']) && ($_GET['g'] + 0 > 0)) $g = $_GET['g']; else $g = 32.185039370; if (isset($_GET['q']) && ($_GET['q'] + 0 > 0)) $q = $_GET['q']; else $q = 0.00049999; if (isset($_GET['a']) && ($_GET['a'] + 0 > 0)) $a = $_GET['a']; else $a = 1.640419948; } // perform calculations in Imperial $H = $F/$g; $lambda = $H/$q; $x = (exp($a/(2*$lambda)) - exp(-$a/(2*$lambda))) / 2; $l = 2*$lambda*$x; $f = ($a/4)*sqrt(6*(($l/$a)-1)); $oF = $F; $F = $F*4.44822/(0.4536*0.3048); $sag = $lambda * (cosh($a/(2*$lambda)) - 1); $S = 2*$lambda*sinh($a/(2*$lambda)); $err = (($S/$a) - 1)*100; $F = $oF; if (($a == 0) or ($F == 0) or ($q == 0)) { $f = 0; $percent_error = 0; } else { $percent_error = ((($l/$a)-1)*100)/2; } // convert answers from metric to Imperial $l = $l/0.0254/12; $f = $f/0.0254/12; ?>

and here is the link to the actual website calculator.
http://www.spaceagecontrol.com/calccabm.htm
Link to comment
Share on other sites

You may want to check with the creator of the code to make sure that they will allow you to use it a different way.

In order to do what you want...take that block of code and have it execute inside of an excel spreadsheet, you will have to rewrite it from php to vbscript, as a macro in excel.
Link to comment
Share on other sites

It mainly depends what the output is to be, if it's a spreadsheet grid then you can convert to Excel CSV, DIF or XML. XML gives you the most options without having to use anything other than standard PHP functions.

If it's graphs etc. that you want in the spreadsheet then it's a bit of a different matter.
Link to comment
Share on other sites

Adding a few linebreaks should clarify if. The first bit checks for valid input and substitutes default values where input is 0.

The second bit shows the formulae for your cells.

[code]<?php
if (isset($_GET['F']) && ($_GET['F'] + 0 > 0))
$F = $_GET['F'];
else $F = 0.674427074;
if (isset($_GET['g']) && ($_GET['g'] + 0 > 0))
$g = $_GET['g'];
else $g = 32.185039370;
if (isset($_GET['q']) && ($_GET['q'] + 0 > 0))
$q = $_GET['q'];
else $q = 0.00049999;
if (isset($_GET['a']) && ($_GET['a'] + 0 > 0))
$a = $_GET['a'];
else $a = 1.640419948; }
// perform calculations in Imperial
$H = $F/$g;
$lambda = $H/$q;
$x = (exp($a/(2*$lambda)) - exp(-$a/(2*$lambda))) / 2;
$l = 2*$lambda*$x;
$f = ($a/4)*sqrt(6*(($l/$a)-1));
$oF = $F;
$F = $F*4.44822/(0.4536*0.3048);
$sag = $lambda * (cosh($a/(2*$lambda)) - 1);
$S = 2*$lambda*sinh($a/(2*$lambda));
$err = (($S/$a) - 1)*100;
$F = $oF;
if (($a == 0) or ($F == 0) or ($q == 0)) {
$f = 0; $percent_error = 0;
}
else {
$percent_error = ((($l/$a)-1)*100)/2;
}
// convert answers from metric to Imperial
$l = $l/0.0254/12;
$f = $f/0.0254/12;
?>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.