Jump to content

Archived

This topic is now archived and is closed to further replies.

patto

PHP to excel spreadsheet help

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

Share this post


Link to post
Share on other sites
What your asking doesn't really make sense.  Please clarify.

Unless you are using a Microsoft server and can use COM there is no want to output a .xls file.  However, you can output a comma delimited file (CSV) that will open in Excel without COM.

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.