@mix_gorbachev

Как отдать правильно excel файл в php с настройками безопасности?

Добрый день для отдачи выгрузки использую вот так вот класс
Проблема заключается в том что в 2007 все открывается корректно, но в версия выше 2010 выдает только Защищенный просмотр. Как это исправить?
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;
    }
}
  • Вопрос задан
  • 489 просмотров
Решения вопроса 1
Keanor
@Keanor
Ведущий разработчик
В защищенном просмотре обычно пишется по какой причине файл открыт именно в защищенном просмотре, что там написано? https://support.office.com/ru-ru/article/%D0%A7%D1...
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
YCLIENTS Москва
от 200 000 до 350 000 ₽
Ведисофт Екатеринбург
от 25 000 ₽
ИТЦ Аусферр Магнитогорск
от 100 000 до 160 000 ₽