Laravel-excel: Does library have any option for export csv encoding? I need to export csv file as sjis-win.

Created on 10 Nov 2018  ·  12Comments  ·  Source: Maatwebsite/Laravel-Excel

Prerequisites

Versions

  • PHP version: 7.1.3
  • Laravel version: 5.7
  • Package version: 3.1

Description

I need to export my csv file as sjis-win because my customer need to open csv file on microsoft excel and all character is broken with UTF-8 encoding. Any help?

Most helpful comment

I am having the same issue. I need the .csv file in "Windows-1252", so i use mb_convert_encoding() in my bindValue function.

public function bindValue(Cell $cell, $value)
    {
        $value = mb_convert_encoding($value, "Windows-1252");
        return parent::bindValue($cell, $value);
    }

But testing with String "Düöälev" just debugs to D���lev and the cell value in the csv output is just empty.
Also the generated file is still UTF-8 encoded.

All 12 comments

I need to export my csv file as sjis-win because my customer need to open csv file on microsoft excel and all character is broken with UTF-8 encoding. Any help?

Please fill in the issue template, we need to know the versions to be able to help you

Please fill in the issue template, we need to know the versions to be able to help you

Can you read my update issue again i have already update my issue problem?

@hoangdo2603 you can try setting use_bom to true: https://github.com/Maatwebsite/Laravel-Excel/blob/3.1/config/excel.php#L49

@patrickbrouwers After change this config, i just only need to convert my data with mb_encoding_convert to sjis-win right bro?

I would first try with mb_encoding_convert, but if that doesn't work, you'll to use mb_encoding_convert yes.

@patrickbrouwers i already try to change config use_bom to true and use mb_econding_convert with or without still cannot have right value when i export csv to shift-jis.
Sample text need to convert: 返信

@patrickbrouwers i already try to use mb_convert_encoding and change config use_bom to true. However i still got problem. String output get be null and have something like this when i debug it:
b"üyâåâjâtâHü[âÇæÒâRâôârâjÄxòÑùpÄåüAìçÅhé╔é┬éóé─üz46"
My original string was: 【ユニフォーム代コンビニ支払用紙、合宿について】46
I cannot use mb_convert_encoding to convert this string from UTF-8 to SJIS

@hoangdo2603
Did you solve this problem ?

I am having the same issue. I need the .csv file in "Windows-1252", so i use mb_convert_encoding() in my bindValue function.

public function bindValue(Cell $cell, $value)
    {
        $value = mb_convert_encoding($value, "Windows-1252");
        return parent::bindValue($cell, $value);
    }

But testing with String "Düöälev" just debugs to D���lev and the cell value in the csv output is just empty.
Also the generated file is still UTF-8 encoded.

can we request update on this. to have export encoding like shift-jis

Was this page helpful?
0 / 5 - 0 ratings