Bom estou com um problema e sou novato.
Meu cliente criou im fluxo de caixa em uma planilha Excel Dinâmica, onde pego a planilha faço a inserção dos dados e depois mando via download. Porém ao fazer o Download a formula Dinâmica é perdida.
Achei algo que daria certo porém não sei trabalhar com essa informação.
https://github.com/svrnm/exceldatatables
Abaixo segue meu código onde uso PHPExcel.
//require_once ‘/prod/third/phpexcel/PHPExcel.php’;
$sessionid = [usr_login];
//require_once ‘/prod/third/phpexcel/IOFactory.php’;
///identify the version of .xls file:
$v_empresa = [var_empresa];
///$v_empresa = ‘teste de planilha’;
$inputFileName=’…/inc/FluxoGesfin_Modelo.xlsx’;
$cklin=‘S’;
function removeracento($str){
$from = ‘àâêôûãõáéíóúçüÀÂÊÔÛÃÕÁÉÍÓÚÇÜ`~!#$%^&*()+=|/{}[]:;,<>¶ª°ºæ¨Æø£Øƒªº¿®½¼ßµþýÝ’;
$to = 'aaeouaoaeioucuAAEOUAOAEIOUCU ';
//$from = ‘ÀÁÃÂÉÊÍÓÕÔÚÜÇàáãâéêíóõôúüç’;
//$to = ‘AAAAEEIOOOUUCaaaaeeiooouuc’;
return strtr($str, $from, $to);
}
require_once $this->Ini->path_third . ‘/phpexcel/PHPExcel.php’;
require_once $this->Ini->path_third . ‘/phpexcel/PHPExcel/IOFactory.php’;
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
//load the file
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
///echo date(‘H:i:s’) .
//set active sheet, or choose which sheet you want to edit:
$objPHPExcel->setActiveSheetIndex(0);
///trocar sheet
//set active sheet, or choose which sheet you want to edit:
$objPHPExcel->setActiveSheetIndex(1);
sc_select(meus_dados, "select datalan,razao_social,descricao,agrupamento,sum(vlr_pagar) from grid_fluxo_simplesr_a where extract(year from datalan)=2016 and usuario=’$sessionid’ group by lancamento,datalan,agrupamento order by agrupamento_id,datalan,lancamento ");
$row=3;
if ({meus_dados} === false)
{
echo "Erro de acesso. Mensagem = " . {meus_dados_erro};
}
else
{
while (!$meus_dados->EOF){
$objPHPExcel->getActiveSheet()->SetCellValue('G'.$row, $meus_dados->fields[0]);
$objPHPExcel->getActiveSheet()->SetCellValue('H'.$row, removeracento($meus_dados->fields[1]));
$objPHPExcel->getActiveSheet()->SetCellValue('I'.$row, removeracento($meus_dados->fields[2]));
$objPHPExcel->getActiveSheet()->SetCellValue('J'.$row, removeracento($meus_dados->fields[3]));
if ( $meus_dados->fields[4] > 0 ) {
$objPHPExcel->getActiveSheet()->SetCellValue('K'.$row, $meus_dados->fields[4]); }
else { $objPHPExcel->getActiveSheet()->SetCellValue('L'.$row, ($meus_dados->fields[4]*-1)); }
$meus_dados->MoveNext();
$row = ++$row;
}
$meus_dados->Close();
}
/// saldo inicial
sc_select(meus_dados, "select sum(saldoinicial) from contacorrente where RELFLUXO=‘S’ ");
$objPHPExcel->getActiveSheet()->SetCellValue(‘T3’, $meus_dados->fields[0]);
$objPHPExcel->getActiveSheet()->setCellValue(‘T4’, removeracento($v_empresa));
/// finalizar planilha
header(“Content-Type: application/vnd.ms-excel”);
///header(“Content-Disposition: attachment; filename=“BD_fluxogesfin_real.xlsx””);
header(“Content-Disposition: attachment; filename=“BD_real.xlsx””);
header(“Cache-Control: max-age=0”);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWriter->save(“php://output”);