Asked  8 Months ago    Answers:  5   Viewed   60 times

Can any one please tell me Why PHPExcel does not allow more than 5000 rows. I am using an open-source PHPExcel for report generation on my projects and i could not write more than 5000 rows of data from Mysql-DB. My result set fetch 7230 records when the query is executed. How do i fix it..



Almost certainly this is a timeout or a memory issue. The only PHPExcel limit for worksheets size is 65,536 rows and 256 (IV) columns (when using the Excel5 Writer); or 1,048,576 rows and 16,384 (XFD) columns (when using the Excel2007 Writer).

Ensure that your error logging is always enabled... use try/catch blocks to trap for any PHPExcel Exceptions. And read the PHPExcel site discussion threads on memory and performance.

Wednesday, March 31, 2021
answered 8 Months ago

When you set cell values individually, you have the option of setting the datatype explicitly, but when you use the fromArray() method, you don't have this option.

However, by default, PHP uses a default value binder to identify datatypes from the values passed, and set the cell datatype accordingly. This default behaviour is defined in a class /PHPExcel/Cell/DefaultValueBinder.php.

So you can create your own value binder, as described in the PHPExcel Documentation, that would set every value as a string datatype.

Something like:

class PHPExcel_Cell_MyColumnValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
    protected $stringColumns = [];

    public function __construct(array $stringColumnList = []) {
        // Accept a list of columns that will always be set as strings
        $this->stringColumns = $stringColumnList;

    public function bindValue(PHPExcel_Cell $cell, $value = null)
        // If the cell is one of our columns to set as a string...
        if (in_array($cell->getColumn(), $this->stringColumns)) {
            // ... then we cast it to a string and explicitly set it as a string
            $cell->setValueExplicit((string) $value, PHPExcel_Cell_DataType::TYPE_STRING);
            return true;
        // Otherwise, use the default behaviour
        return parent::bindValue($cell, $value);

// Instantiate our custom binder, with a list of columns, and tell PHPExcel to use it
PHPExcel_Cell::setValueBinder(new PHPExcel_Cell_MyColumnValueBinder(['A', 'B', 'C', 'E', 'F']));

$objPHPExcel = new PHPExcel();
Friday, May 28, 2021
answered 5 Months ago

Have you tried...

$mail->AddAttachment($full_path_to_file, "report.xls");
Saturday, May 29, 2021
answered 5 Months ago

Extending a fundamental type such as a String or an array opens up security holes. If Java let you extend an array, its methods that take arrays would become insecure. That is why strings are final, and arrays cannot be extended at all.

For example, you could override the clone() method, and return an array of incorrect size. This has a potential of breaking the logic of system code that takes an array as its parameter.

On top of that, arrays are special objects in Java, in that they do not have a class definition.

There are two solution to the problem that you are trying to solve:

  • You could put the logic into a helper class with static methods, similar to Collections, etc. or
  • You could encapsulate an array inside your IntArrayExtension class, and provide wrapper methods for accessing the array and its additional features.
Tuesday, August 17, 2021
answered 3 Months ago

Try this:

from tensorflow import keras
from tensorflow.keras.layers import Conv2D

model = keras.Sequential()
model.add(Conv2D(1, (3, 3), padding='same', input_shape=(28, 28, 1)))

You are mixing a tf.keras Sequential model with a keras Conv2D layer (instead of a tf.keras Conv2D layer.)

Or, as remarked below, use actual Keras:

import keras
from keras.models import Sequential
from keras.layers import Conv2D

model = Sequential()
model.add(Conv2D(1, (3, 3), padding='same', input_shape=(28, 28, 1)))
Tuesday, August 31, 2021
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :