S
S
salem_sakarov2014-04-17 11:07:53
PHP
salem_sakarov, 2014-04-17 11:07:53

How to solve the problem with uploading data to Excel?

Good afternoon, colleagues! I need your help!
Situation: site on Bitrix, uploading questionnaires with a bunch of fields in xml as xls, everything works locally, on hosting it only works if there are no more than 2.5k+ entries (file ~ 27mb). More than 2.5K+ returns an empty file of 0 bytes.
memory_limit 256M
max_execution_time 60
Where am I going wrong? What's wrong?

$file = $arFilter['PROPERTY_ANKETA_TYPE'].'_tmp.php';
$content =  renderPhpToString($file,array('arData'=>$arData));

  function renderPhpToString($file, $vars=null)
  {
    if (is_array($vars) && !empty($vars)) {
      extract($vars);
    }
    ob_start();
    include $file;
    return ob_get_clean();
  }
  
  
    header('Content-Type: application/vnd.ms-excel; charset=utf-8;');
    header('Content-Disposition: attachment;filename="report_'.$arFilter['PROPERTY_ANKETA_TYPE'].'_' . date("d-m-Y") . '.xls"');
    header('Cache-Control: max-age=0');
    header('Cache-Control: no-store, no-cache, must-revalidate');
    header('Cache-Control: post-check=0, pre-check=0', FALSE);
    header('Pragma: no-cache'); 
  echo $content;
    exit;

In excel_tmp.php just foreach
<?foreach($arData as $i => $arr):?>
   <Row>
   <?foreach($arr as $k => $value):?>
    <Cell><Data ss:Type="String"><?=$value?></Data></Cell>
   <?endforeach;?>
   </Row>
<?endforeach;?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim Yakovlev, 2014-04-17
@FrimInc

at you nginx a file does not cut a case? What is the value of client_max_body_size ?
Well, you can throw off the response headers, all of a sudden there is something there.

S
salem_sakarov, 2014-04-18
@salem_sakarov

Hoster temporarily increased memory_limit , everything worked, unfortunate 2.5 records....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question