Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

manhnguyen's avatar

Error unicode - Laravel Excel

Hi every body, I have a problem, can you guys help me ?

I use Maatwebsite/Laravel-excel to export japanese text from database to csv file.

When I open export file using MS Excel, I got a lot of symbols. But when I open it using Notepad++ or upload to Google Drive, I got exactly I want.

How can I fix it ?

This is my code :

public function export($type, $properties, $data)
{
    if (in_array($type, self::EXPORT_TYPE)) {
        try {
            $export = Excel::create($properties['_title'], function ($excel) use ($data, $properties) {
                $excel->sheet('Sheet', function ($sheet) use ($data) {
                    foreach ($data as $item) {
                        $sheet->fromArray($item);
                    }
                });
            });
            $csvFileExportPath = 'csv/exports';
            $resultExport = $export->store($type,storage_path($csvFileExportPath), $file = true, $returnInfo = true);
            return $resultExport['file'];
        } catch (Exception $error) {
            throw $error;
        }
    }
}
0 likes
2 replies
AddWebContribution's avatar

Might be this is the cause. The document contains a font that is not installed on your computer, and Word substituted an available font that doesn't include the same symbols and characters available in the original font.

1 like
manhnguyen's avatar

thank you @saurabh , but when I upload to GG Drive, then download, It display the right way.

Please or to participate in this conversation.