php – Create spreadsheet by adding images and changing line color

Question:

This method creates an Excel spreadsheet, with int and string :

public function arrayToXls($input) {
    // BoF
    $ret = pack('ssssss', 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);

    // array_values is used to ensure that the array is numerically indexed
    foreach (array_values($input) as $lineNumber => $row) {
        foreach (array_values($row) as $colNumber => $data) {
            if (is_numeric($data)) {
                // number, store as such
                $ret .= pack('sssssd', 0x203, 14, $lineNumber, $colNumber, 0x0, $data);
            } else {
                // everything else store as string
                $len = strlen($data);
                $ret .= pack('ssssss', 0x204, 8 + $len, $lineNumber, $colNumber, 0x0, $len) . $data;

            }
        }
    }


    //EoF
    $ret .= pack('ss', 0x0A, 0x00);

    return $ret;
}

I would like to add an image, could they help with the change I need to make in this line for that?

$ret .= pack('ssssss', 0x204, 8 + $len, $lineNumber, $colNumber, 0x0, $len) . $data;

And I also need to change the color of the lines

$ret .= pack('ss', 0x0A, 0x00);

Does anyone have any documentation or have they done this?

Answer:

I ended up choosing to use the PHP Excel library ) .

It was the easiest way to perform this action.

Scroll to Top