« Reply #2 on: January 05, 2008, 02:14:49 PM »
All,
Resolved with this code:<?php
define('TITLE1', 'Main Title');
define('TITLE2', 'Subtitle');
define('ORGFIL', 'source.xls');
define('ORGSHT', 'sheet1');
define('OCLROW', '5 324');
define('TRGFIL', 'target.xls');
define('TRGSHT', 'sheet2');
define('TCLROW', '11 57');
include('Zips/TBS Excel/tbs_class.php'); //Load TBS Class
include('Zips/TBS Excel/tbs_plugin_excel.php'); //Load TBS plugin
function open_xcel($myfile,$mysheet) {
$opn_str = $myfile;
$TBS = new clsTinyButStrong;
$TBS->PlugIn(TBS_INSTALL,TBS_EXCEL);
$TBS->LoadTemplate($myfile);
// $TBS->MergeBlock('book',$books); //Process Alternate Cell Mapping
// $TBS->MergeBlock('tsk1,tsk2',$tasks); //Process Alternate Cell Mapping
// $TBS->MergeBlock('emp',$employees); //Process Alternate Cell Mapping
$TBS->PlugIn(TBS_EXCEL,TBS_EXCEL_FILENAME,'result.xls');
$TBS->Show();
}
$but_vin = '<button type=submit name=iview onclick="value=\'invw\'">'.
'View Input File</button>';
$but_vot = '<button type=submit name=oview onclick="value=\'outv\'">'.
'View Output File</button>';
$but_prc = '<button type=submit name=proc onclick="value=\'proc\'">'.
'Process</button>';
$but_prt = '<button type=submit name=prnt onclick="value=\'prnt\'">'.
'Print Output</button>';
$two_spc = ' ';
$but_lin = $but_prc.$two_spc.$but_vot.$two_spc.$but_prt;
$vot_val = '"D:\Local Files\Company Relations, Projects & Bids\Active\Avid Business Networks\avid phone quote.xls"';
$vin_val = $HTTP_POST_VARS['infil'];
$fld_vin = "<input type=file size=80 name=infil value=$vin_val ".
"onclick=\"document.forms['scrub'].submit();\">";
$fld_vot = "<input type=text size=100 name=otfil value=$vot_val>";
$vot_val = 'D:\Local Files\Company Relations, Projects & '.
'Bids\Active\Avid Business Networks\avid phone quote.xls';
if ($HTTP_POST_VARS['iview']=='invw') {
$tstbut = $HTTP_POST_VARS['iview'];
}
if ($HTTP_POST_VARS['oview'] == 'outv') {
$tstbut = $HTTP_POST_VARS['oview'];
}
if ($HTTP_POST_VARS['proc']=='proc') {
$tstbut = $HTTP_POST_VARS['proc'];
}
if ($HTTP_POST_VARS['prnt']=='prnt') {
$tstbut = $HTTP_POST_VARS['prnt'];
}unset ($HTTP_POST_VARS['proc'],$HTTP_POST_VARS['form'],
$HTTP_POST_VARS['iview'],$HTTP_POST_VARS['oview'],
$HTTP_POST_VARS['prnt']);
switch ($tstbut) {
case 'invw': // Open/Edit the INPUT file.
if ($HTTP_POST_VARS['infil'] != "") {
$vin_val = $HTTP_POST_VARS['infil'];
$vin_val = realpath($vin_val);
if (file_exists($vin_val)) {
$rc = open_xcel($vin_val, ORGSHT);
} else {
echo "File => $vin_val <= not found! <br>";
}
} else {
echo "Must select a file to procces or read!";
}
break;
case 'outv': // Open/Edit the OUTPUT file.
if ($HTTP_POST_VARS['otfil'] != "") {
if (file_exists($vot_val)) {
if ($PROCD == 'Processed') {
$rc = open_xcel($vot_val, ORGSHT);
} else {
echo "No OUTPUT File Processed <br>";
}
} else {
echo "File => $vot_val <= not found! <br>";
}
}
break;
case 'proc': // Dump the INPUT file into the OUTPUT file.
if ($HTTP_POST_VARS['infil'] != "") {
$vin_val = $HTTP_POST_VARS['infil'];
$vin_val = realpath($vin_val);
if (file_exists($vin_val)) {
if ($PROCD != 'Processed') {
// $rc = XL_proc($vin_val,$vot_val);
} else {
echo "File already Processed <br>";
}
} else {
echo "File => $vot_val <= not found! <br>";
}
} else {
echo "Must select a file to procces or read!";
}
break;
case 'prnt':
if ($HTTP_POST_VARS['otfil'] != "") {
if (file_exists($vot_val)) {
// $rc = open_xcel($vot_val, ORGSHT);
} else {
echo "File => $vot_val <= not found! <br>";
}
}
break;
}
$TIT1 = TITLE1;
$TIT2 = TITLE2;
ob_start();
?>
<html>
<head>
<title>Excel Scrub Processor</title>
</head>
<body>
<FORM name="scrub" METHOD="POST" ACTION="<?php echo $_SERVER['PHP_SELF']; ?>">
<table width='80%' border=0 align=center>
<tr height=50>
<td align=center> </td>
</tr>
<tr>
<td align=center>
<table width='100%' border=0 align=center bgcolor='#55aaee'>
<tr>
<td colspan=4 align=center> </td>
</tr>
<tr>
<td colspan=4 align=center>
<h1><?php echo $TIT1; ?></h1>
<b><?php echo $TIT2; ?></b>
</td>
</tr>
<tr>
<td width=25> </td>
<td> </td>
<td> </td>
<td width=25> </td>
</tr>
<tr>
<td> </td>
<td>
<?php echo $fld_vin; ?>
</td>
<td align=left width=100>
<button type=submit name='iview' onclick="value='invw'">View Input File</button>
</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan=2>
<?php echo $fld_vot; ?> <b><= Output file</b>
</td>
<td> </td>
</tr>
<tr>
<td colspan=4> </td>
</tr>
<tr>
<td colspan=4 align=center>
<?php echo $but_lin; ?>
</td>
</tr>
<tr>
<td colspan=4> </td>
</tr>
</table>
</tr>
</table>
</form>
</body>
</html>
<?php
ob_end_flush();
?>Button processing now working but functions are still in progress.
Thanks all!
OMR