Comunidad de diseño web y desarrollo en internet online

como generar una tabla generada en Excel en PHP?

Citar            
MensajeEscrito el 13 Feb 2009 01:00 pm
Hola amigos, aca acudiendo a ustedes para que me puedan iluminar para resolver este problema.
tengo la siguiente tabla, que esta generada en excel y la tengo que programar con PHP.

(http://desmond.110mb.com/tabla.jpg)
Tengo el siguiente codigo:

Código :

$cuota_mes = 661.66;
$monto = 11188;
$interes_mes_1 = $monto*(8/1200);
$amortizacion_mes_1 = $cuota_mes - $interes_mes_1;
$acumulada_mes_1 = $amortizacion_mes_1;
$pendiente_mes_1 = $monto - $amortizacion_mes_1;
$meses = 18;

echo "<table border='1'>";
echo "<tr>";
echo "<td width='120' align='center' rowspan='2'>Numero</td>";
echo "<td width='120' align='center' rowspan='2'>Amortizaci&oacute;n Mes</td>";
echo "<td width='80' align='center' rowspan='2'>Interes Mes</td>";
echo "<td width='80' align='center' rowspan='2'>Total Mes</td>";
echo "<td colspan='2' align='center'>Amortizaci&oacute;n</td>";
echo "<tr>";
echo "<td width='80' align='center'>Acumulada</td>";
echo "<td width='80' align='center'>Pendiente</td>";
echo "</tr>";
echo "</tr>";
echo "<tr>";
for($x=1;$x<=5;$x++)
{
   $interes_mes_1 = $monto*(8/1200);
   $amortizacion_mes_1 = $cuota_mes - $interes_mes_1;
   $acumulada_mes_1 = $amortizacion_mes_1;
   $pendiente_mes_1 = $monto - $amortizacion_mes_1;
   echo "<td>".$x."</td>";
   echo "<td>".number_format($amortizacion_mes_1,2)."</td>";
   echo "<td>".number_format($interes_mes_1,2)."</td>";
   echo "<td>".number_format($cuota_mes,2)."</td>";
   echo "<td>".number_format($acumulada_mes_1,2)."</td>";
   echo "<td>".number_format($pendiente_mes_1,2)."</td>";
   echo "<tr>";
   for ($y=1;$y<=2;$y++)
   {
      $interes_mes_2 = $pendiente_mes_1 * (8/1200);
      $amortizacion_mes_2 = $cuota_mes - $interes_mes_2;
      $acumulada_mes_2 = $amortizacion_mes_1 + $amortizacion_mes_2;
      $pendiente_mes_2 = $pendiente_mes_1 - $amortizacion_mes_2;
      echo "<td></td>";
      echo "<td>".number_format($amortizacion_mes_2,2)."</td>";
      echo "<td>".number_format($interes_mes_2,2)."</td>";
      echo "<td>".number_format($cuota_mes,2)."</td>";
      echo "<td>".number_format($acumulada_mes_2,2)."</td>";
      echo "<td>".number_format($pendiente_mes_2,2)."</td>";
      echo "</tr>";
   }
   echo "</tr>";
}
echo "</tr>";
echo "</table>"


pero solo saco las 2 primeras filas, y al querer sacar las demas "jalando" los valores del for con Y al for con X no me

jalan los datos, osea al poner

Código PHP :

echo $pendiente_mes_2;
en el primer for no me sale nada por ende no puedo sacar

los demas calculos.

esta bien que use los for? o debo usar otro bucle? o como puedo hacer para generar esto?

les agradeceria mucho la ayuda que puedan darme, gracias.

ahh me olvidaba, tendria que ser para 18 filas o meses como para 5 o para 30 etc, dependiendo del usuario. osea el

x<=$meses.

Por desmond

23 de clabLevel



 

firefox
Citar            
MensajeEscrito el 16 Feb 2009 04:39 pm

Por DanielJimenez

70 de clabLevel



Genero:Masculino  

Web Developer

mozilla
Citar            
MensajeEscrito el 19 Feb 2009 09:39 pm
lo resolvi con un for que lo posteo tal cual lo tengo:

Código :

<?
$cuota_mes = 661.66;
$monto = 11188;
$interes_mes_1 = $monto*(8/12/100);
$amortizacion_mes_1 = $cuota_mes - $interes_mes_1;
$acumulada_mes_1 = $amortizacion_mes_1;
$pendiente_mes_1 = $monto - $amortizacion_mes_1;
$meses = 18;
?>
<table width="361" border="0" cellspacing="2" cellpadding="1">
  <tr>
    <td width="295"><div align="right" class="style2">MONTO</div></td>
    <td width="56"><div align="right" class="style2"><? echo $monto; ?></div></td>
  </tr>
  <tr>
    <td width="295"><div align="right" class="style2">INTERES MENSUAL </div></td>
    <td width="56"><div align="right" class="style2"><? echo number_format($interes_mes_1,2); ?></div></td>
  </tr>
  <tr>
    <td width="295"><div align="right" class="style2">TIEMPO DE PAGO EN MESES </div></td>
    <td width="56"><div align="right" class="style2"><? echo $meses; ?></div></td>
  </tr>
  <tr>
    <td width="295"><div align="right" class="style2">CUOTA MES EN USD </div></td>
    <td width="56"><div align="right" class="style2"><? echo $cuota_mes; ?></div></td>
  </tr>
</table>
<br />
<table width="600" border="1" cellspacing="1" cellpadding="1">
  <tr>
    <td width="33"><div align="center"><span class="style1"></span></div></td>
    <td width="110"><div align="center" class="style1"><strong>AMORTIZACION</strong></div></td>
    <td width="110"><div align="center" class="style1"><strong>INTERES</strong></div></td>
    <td width="110"><div align="center" class="style1"><strong>TOTAL</strong></div></td>
    <td colspan="2"><div align="center" class="style1"><strong>AMORTIZACION</strong></div></td>
  </tr>
  <tr>
    <td width="33"><div align="center" class="style1"><strong>nro</strong></div></td>
    <td width="110"><div align="center" class="style1"><strong>MES</strong></div></td>
    <td width="110"><div align="center" class="style1"><strong>MES</strong></div></td>
    <td width="110"><div align="center" class="style1"><strong>MES</strong></div></td>
    <td width="110"><div align="center" class="style1"><strong>ACUMULADA</strong></div></td>
    <td width="110"><div align="center" class="style1"><strong>PENDIENTE</strong></div></td>
  </tr>
  <?
  $amort=0;
  $inter=0;
  $cuota=0;
  $acumu=0;
  $pendi=$monto;
for($x=0;$x<=$meses;$x++){
  ?>
  <tr>
    <td width="33"> <span class="style2"><? echo $x;?></span></td>
    <td width="110"><span class="style2"><? echo number_format($amort,2); ?></span></td>
    <td width="110"><span class="style2"><? echo number_format($inter,2); $inter=$pendi*8/12/100;?></span></td>
    <td width="110"><span class="style2"><? echo number_format($cuota,2); $cuota=$cuota_mes*1;?></span></td>
    <td width="110"><span class="style2"><? echo number_format($acumu,2); ?></span></td>
    <td width="110"><span class="style2"><? echo number_format($pendi,2); $amort=$cuota-$inter; $pendi=$pendi-$amort; $acumu=$acumu+$amort;?></span></td>
  </tr>
  <? } ?>


ojala le sirva a alguien

Por desmond

23 de clabLevel



 

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.