0

I have no idea how to use Excel Extended Format. I'm trying to add '%' or red color(when data is belong zero).

Using those scripts :

    function xlsBOF() {
        echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);  
        return;
    }

    function xlsEOF() {
        echo pack("ss", 0x0A, 0x00);
        return;
    }

    function xlsWriteNumber($Row, $Col, $Value) {
        echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
        echo pack("d", $Value);
        return;
    }

    function xlsWriteLabel($Row, $Col, $Value ) {
        $L = strlen($Value);
        echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
        echo $Value;
    return;
    }


    xlsBOF();
      xlsWriteLabel(1,1,'Smth');


    $val = -12,23;
    /* This number should be exported red with %,
       i think i have to use this '0,00%;[RED]-0,00%' but no idea how
    */
    xlsWriteNumber(2,1,$val);

    xlsEOF();
    exit();

Thanks in advance.

1 Answer 1

1

You need to write the style information as a style (xf) entry, then setting the 0x0 value in your xlsWriteLabel to identify using the style xf index:

See PHP to Excel, bold font for a more detailed description of how to do this (it does identify the colour settings as well as bold, despite the title of the thread), then look at better libraries for writing Excel files.

You can find a list of libraries in the responses to this question

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.