shurix Posted January 24, 2012 Report Share Posted January 24, 2012 Problēma exportējot datus uz excel failu. Palielam viss darbojas, vienīgā problēma, ka tiek izkropļotas garumzīmes un mīkstinājuma zīmes. Kā varētu pielabot šo kodu, lai problēmu novērstu un garumzīmes rādītos? function cleanData(&$str) { $str = preg_replace("/\t/", "\\t", $str); $str = preg_replace("/\r?\n/", "\\n", $str); if(mb_strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"'; } $filename = "poll_".$pollid."_" . date('Ymd') . ".xls"; header("Content-Disposition: attachment; filename=\"$filename\""); header("Content-Type: application/vnd.ms-excel"); $flag = false; foreach($excel as $row) { if(!$flag) { echo implode("\t", array_keys($row)) . "\r\n"; $flag = true; } array_walk($row, 'cleanData'); echo implode("\t", array_values($row)) . "\r\n"; } Quote Link to comment Share on other sites More sharing options...
briedis Posted January 24, 2012 Report Share Posted January 24, 2012 Es nezinu kāds ir risinājums, bet visdrīzāk sāktu ar meklēšanu google - "php excel utf8" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.