excel - return binary code instead of string in response php -
i want read excel file php , send content client. want changing content type , other html headers forcefulness browser download file instead of showing content. ok , user can download file when tries open contents not displayed in right format , shape. thing comes mind should not send response in unicode string , have in binary format excel can know it. current code :
$filename = $_get['file']; $ext = $_get['type']; $filename .= '.' . $ext; $path = "../generatedreports/" . $filename; header('content-type: application/vnd.ms-excel;'); header('content-disposition: attachment; filename=' . $filename); header("pragma: public"); header("expires: 0"); header("cache-control: must-revalidate, post-check=0, pre-check=0"); header("cache-control: public", false); header("content-description: file transfer"); header("accept-ranges: bytes"); header("content-transfer-encoding: binary"); header("content-length: " . filesize($path)); $size = filesize($path); $f = fopen($path, 'r'); $content = fread($f, $size); echo $content;
any solution?
please seek below code,
echo unicode2utf8(hexdec("00ce")); // result: Î // or function recognize u+ in front end of string, , skip show character function unicodecodepointtochar($str) { if (substr($str,0,2) != "u+") homecoming $str; $str = substr($str,2); // skip u+ homecoming unicode_to_utf8(array(hexdec($str))); } echo unicodecodepointtochar("u+00ce"); // result: Î
php excel binary
No comments:
Post a Comment