All pastes #840828 Raw Edit

Excel Scrub

public text v1 · immutable
#840828 ·published 2008-01-04 00:52 UTC
rendered paste body
<?php
   define('TITLE1', 'Avid Business Networks - Excel Scrub');
   define('TITLE2', 'for Samsung Telephone Systems');
   define('ORGFIL', 'AVID Pricesheet.xls');
   define('ORGSHT', 'Samsung Systems');
   define('OCLROW', '5 324');
   define('TRGFIL', 'avid phone quote.xls');
   define('TRGSHT', 'pvinv');
   define('TCLROW', '11 57');
   include('Zips/TBS Excel/tbs_class.php');
   include('Zips/TBS Excel/tbs_plugin_excel.php');

   function open_xcel($myfile,$mysheet) {
      $opn_str = $myfile.".".$mysheet;
      $opn_str = stripslashes($myfile);
//      $opn_str = 'E:/Local Files/Company Relations, Projects & Bids/Active/Avid/avid phone quote.xls';
//echo "Opening => $opn_str <br>";
      $TBS = new clsTinyButStrong;
      $TBS->PlugIn(TBS_INSTALL,TBS_EXCEL);
      $TBS->LoadTemplate($opn_str);
      $TBS->PlugIn(TBS_EXCEL,TBS_EXCEL_FILENAME,'result.xls');
      $TBS->Show();
   }

   function set_but($mybut) {
echo "Button => $mybut <br>";
      $tstbut = $mybut;
      if (isset($HTTP_POST_VARS['proc'])) {
         $prcstr = $HTTP_POST_VARS['proc'];
      } else {
         $prcstr = "";
      }
      if (isset($HTTP_POST_VARS['form'])) {
         $frmstr = $HTTP_POST_VARS['form'];
      } else {
         $frmstr = "";
      }
      if (isset($HTTP_POST_VARS['iview'])) {
         $invstr = $HTTP_POST_VARS['iview'];
      } else {
         $invstr = "";
      }
      if (isset($HTTP_POST_VARS['oview'])) {
         $otvstr = $HTTP_POST_VARS['oview'];
      } else {
         $otvstr = "";
      }
      if (isset($HTTP_POST_VARS['prnt'])) {
         $prtstr = $HTTP_POST_VARS['prnt'];
      } else {
         $prtstr = "";
      }
      $valstr = "PRC => $prcstr <= ".
                "FRM => $frmstr <= ".
                "INV => $invstr <= ".
                "OTV => $otvstr <= ".
                "PRT => $prtstr <= ".
                "IFL => $prtstr <= ".
                "OFL => $prtstr <= ";
echo "Vals => $valstr <br>";
      unset ($HTTP_POST_VARS['proc'],$HTTP_POST_VARS['form'],
            $HTTP_POST_VARS['iview'],$HTTP_POST_VARS['oview'],
            $HTTP_POST_VARS['prnt']);
echo "Vals => $valstr <br>";
      switch ($tstbut) {
        case "apple":
           echo "i is apple";
           break;
        case "bar":
           echo "i is bar";
           break;
        case "cake":
           echo "i is cake";
           break;
      }   // End Switch
   }      // End Function

   $but_vin = "<input type=button name=iview value=View ".
              "onclick=\"document.forms['scrub'].submit(set_but('infile'));\">";
   $but_vot = "<input type=button name=oview value=View ".
              "onclick=\"document.forms['scrub'].submit(set_but('otfile'));\">";
   if ($HTTP_POST_VARS['infil'] != "") {
//      echo "Found iview! <br>";
      $vin_val = $HTTP_POST_VARS['infil'];
//      echo "File $vin_val <br>";
      $fld_vin = "<input type=file size=80 name=infil value=$vin_val ".
                 "onclick=\"document.forms['scrub'].submit();\">";
      $vot_val = "Test text";
      $fld_vot = "=> ".$vot_val;
      if (file_exists($vin_val)) {
         $rc = open_xcel($vin_val, ORGSHT);
      } else {
         echo "File => $vin_val <= not found! <br>";
      }
   } else {
      $fld_vin = "<input type=file size=80 name=infil>";
   }
   $vot_val = '"D:\Local Files\Company Relations, Projects & Bids\Active\Avid Business Networks\avid phone quote.xls"';
   if ($HTTP_POST_VARS['otfil'] != "") {
      echo "Found oview! <br>";
//      $vot_val = realpath($HTTP_POST_VARS['otfil']);
      $vot_pth = dirname($vot_val);
      $fld_vot = "<input type=text size=100 name=otfil value=$vot_val>";
   } else {
      $fld_vot = "<input type=text size=100 name=otfil value=$vot_val>";
   }
   if (isset($HTTP_POST_VARS['proc'])) {
      echo "Found proc! <br>";
   }
   if (isset($HTTP_POST_VARS['form'])) {
      echo "Found form! <br>";
   }
   if (isset($HTTP_POST_VARS['iview'])) {
      echo "Found inview! <br>";
   }
   if (isset($HTTP_POST_VARS['oview'])) {
      echo "Found otview! <br>";
   }
   $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='75%' border=0 align=center bgcolor='#55aaee'>
   <tr>
   <td colspan=3 align=center>
      <h1><?php echo $TIT1; ?></h1>
      <b><?php echo $TIT2; ?></b>
   </td>
   </tr>

   <tr>
   <td width=25>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   </tr>

   <tr>
   <td>&nbsp;</td>
   <td>
      <?php echo $fld_vin; ?>
   </td>
   <td align=left width=100>
      <button type=submit name=iview>View Input File</button>
   </td>
   </tr>

   <tr>
   <td>&nbsp;</td>
   <td colspan=3>
      <?php echo $fld_vot; ?>&nbsp;<b><= Output file</b>
   </td>
   <td>&nbsp;</td>
   </tr>

   <tr>
   <td colspan=3>&nbsp;</td>
   </tr>

   <tr>
   <td colspan=3 align=center>
      <button type=submit name=oview>View Output File</button>&nbsp;&nbsp;
      <button type=submit name=proc>Process</button>&nbsp;&nbsp;
      <button type=submit name=prnt>Print Output</button>
      <input type=hidden name=form value="">
   </td>
   </tr>
   <tr>

   <td colspan=3>&nbsp;</td>
   </tr>
</table>
</form>
</body>
</html>
<?php
   ob_end_flush();
?>