0
0

More than 1 year has passed since last update.

Ajaxでのファイルダウンロード(CSV)で文字化けした時の対策

Posted at

やりたいこと
・HTMLのDLボタン → Ajax処理でファイル(CSV)ダウンロード
・UTF8のエンコードで出力するプログラムがすでにありそれを利用。SHIFT_JISへの変換はやりたくない
・DLしたUTF8エンコードのファイルをそのままエクセルで開ける。メモ帳で開いて再保存するとかもやりたくない
※バックエンドはかなり古い(クラシックASP)

結論として
・JSのBLOBオブジェクトを利用。JS側でファイル名とBOMをつける
・サーバーサードの出力はCSVの中身のみ(カンマ区切り(+改行)の文字列)ヘッダーなどは不要

参考
https://ameblo.jp/hero-design/entry-12652005689.html

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0