M
M
Mikhail2016-05-12 00:07:05
PHP
Mikhail, 2016-05-12 00:07:05

How to give the correct excel file to php with security settings?

Good afternoon, to return the unloading, I use the class like this.
The problem is that in 2007 everything opens correctly, but in the version above 2010 it only gives Protected View. How to fix it?

class ExportToExcel {
    var $xlsData = "";
    var $fileName = "";
    var $countRow = 0;
    var $countCol = 0;
    var $totalCol = 15;
    function __construct (){
        $this->xlsData = pack( "ssssss", 0x809, 0x08, 0x00,0x10, 0x0, 0x0 );
    }
    // ���� �����
    function RecNumber( $row, $col, $value ){
        $this->xlsData .= pack( "sssss", 0x0203, 14, $row, $col, 0x00 );
        $this->xlsData .= pack( "d", $value );
        return;
    }
    //���� �����
    function RecText( $row, $col, $value ){
        $len = strlen( $value );
        $this->xlsData .= pack( "s*", 0x0204, 8 + $len, $row, $col, 0x00, $len);
        $this->xlsData .= $value;
        return;
    }
    // ��������� �����
    function InsertNumber( $value ){
        if ( $this->countCol == $this->totalCol ) {
            $this->countCol = 0;
            $this->countRow++;
        }
        $this->RecNumber( $this->countRow, $this->countCol, $value );
        $this->countCol++;
        return;
    }
    // ��������� �����
    function InsertText( $value ){
        if ( $this->countCol == $this->totalCol ) {
            $this->countCol = 0;
            $this->countRow++;
        }
        $this->RecText( $this->countRow, $this->countCol, $value );
        $this->countCol++;
        return;
    }
    // ������� �� ����� ������
    function GoNewLine(){
        $this->countCol = 0;
        $this->countRow++;
        return;
    }
    //����� ������
    function EndData(){
        $this->xlsData .= pack( "ss", 0x0A, 0x00 );
        return;
    }
    // ��������� ����
    function SaveFile( $fileName ){
        $this->fileName = $fileName;
        $this->SendFile();
    }
    // ���������� ����
    function SendFile(){
        $this->EndData();
        header ( "Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT" );
        header ( "Cache-Control: no-store, no-cache, must-revalidate" );
        header ( "Pragma: no-cache" );
        header ( "Content-type: application/x-msexcel" );
        header ( "Content-Disposition: attachment; fileName=$this->fileName.xls" );
        print $this->xlsData;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shirshov Alexander, 2016-05-12
@mix_gorbachev

In Protected View, it is usually written for what reason the file is opened in Protected View, what is written there? https://support.office.com/en-us/article/%D0%A7%D1...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question