Hi,
Any body please help me out, am facing the following error


Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 1704 bytes) in C:\xampp\htdocs\phpexcel\Classes\PHPExcel\Style\Borders.php on line 517

Dani AI

Generated

Short answer: the error means PHP hit its memory limit (as said) — raising memory_limit in php.ini (what did) will fix it immediately, but it’s often just a band‑aid. Check for infinite loops or huge in‑memory arrays first (as suggested), and remember per‑directory php.ini uploads can work on some hosts (as noted). (php.net)

Quick diagnostic steps to pin the hotspot: locate the active php.ini and print memory snapshots at critical points. Example helpers:

echo 'php.ini: '. php_ini_loaded_file() . PHP_EOL;
echo 'usage: '. memory_get_usage(true) . ' peak: '. memory_get_peak_usage(true) . PHP_EOL;

Use those prints (or Xdebug/profiler) to see where the largest allocations occur. (php.net)

If PHPExcel is involved (the stack trace shows PHPExcel\Style\Borders.php), try these memory-saving options before blindly increasing limits: read data only ($reader->setReadDataOnly(true)), load only specific sheets (setLoadSheetsOnly()), use a configurable ReadFilter / chunked loading to read rows in batches (trades time for memory), and enable cell caching so cell objects are stored on disk or in php://temp via PHPExcel_Settings::setCacheStorageMethod(...). These techniques are documented and commonly used to handle large workbooks. Example (short):

$reader = PHPExcel_IOFactory::createReader('Excel2007');
$reader->setReadDataOnly(true);
$reader->setLoadSheetsOnly(['Sheet1']);

and set cache before creating the PHPExcel object. (stackoverflow.com)

Practical next steps: instrument and confirm where memory grows; use ini_set('memory_limit','256M') as a short test or run the script from CLI (often higher limits). For very large spreadsheets consider streaming libraries (OpenSpout/Spout) or migrating to PhpSpreadsheet — they handle huge files with tiny memory footprints. If on shared hosting, contact the host about increasing limits or per‑directory ini options. (github.com)

Recommended Answers

All 4 Replies

This means that your script is using more memory than the allowed. If you post the script maybe somebody will be able to help you.

Possible cause might be an endless loop. Check your for and while loops wheter they end as intended.

Hi,
i increased the memory size in php.ini file...its solved thanks

When you don't have permission to modify php.ini, create a php.ini file like this:

-------------------------------
safe_mode = Off
display_errors = Off
disable_functions = 
memory_limit = 128M

upload_max_filesize = 20M
post_max_size = 20M
-------------------------------

then upload to directory in which some files show error like that(eg. admin folder) or simply to all folder ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.