0
我從包含中文字符的unix shell腳本發送報告。如何使excel解釋CSV文件中的中文字符
當我用純文本編輯器打開CSV報告時,我可以看到中文字符,但是當我在Excel中打開CSV報告文件時,我看不到中文字符,但有些亂碼。
我該如何「告訴」excel文件是否包含中文字符集?
這是發送郵件並附加CSV文件的代碼。
send_mail() {
v_mailpart="ZZ_/afg6432dfgkl.94531q"
echo "Mail to be sent to $RPT_SEND_TO"
echo "To: $RPT_SEND_TO
Subject: Blah Report as of $report_date_format;
Content-Type: multipart/mixed; boundary=\"$v_mailpart\"
MIME-Version: 1.0
This is a multi-part message in MIME format.
--$v_mailpart
Content-Type: text/html
Content-Disposition: inline
<html><body><p>Hi All,<p>Please find attached, the daily report <p>Thanks,
<br/>Blah Team</br/><br/><br/></p><p>NOTE: This is an auto-generated email. Do not reply to it. Please send an email to [email protected] in
case of any issues.<p></body></html>
--$v_mailpart
Content-Transfer-Encoding:UTF-8;
Content-Type: text/plain;charset=\"UTF-8\";
Content-Disposition: attachment; filename=blah-report.csv
`cat $spool_file5`" | /usr/sbin/sendmail -t
}
我可以問你這篇文章是如何與Excel相關的嗎?你只是在創建一個電子郵件,而且據我所知,你提供了正確的「Content-Type」。有兩件事對我來說很奇怪:Content-Transfer-Encoding可以真的是UTF-8嗎?我從來沒有聽說過,而且我會用QUOTED-PRINTABLE之類的東西。我也希望在Content-Disposition:attachment之後有一個空行。 ...',但我在電子郵件方面並不是真正的專家,所以我可能在這裏錯了。 – user1934428
@ user1934428嗯,原因是因爲我在Excel中打開CSV並想知道如何「告訴excel」CSV文件包含UTF-8字符集 – anu
然後我誤解了這個問題(因爲您也在標記它「shell」標籤,並顯示將文本文件嵌入到郵件頭中的代碼 - 與控制Excel假定的編碼無關)。也許你可以相應地重寫你的問題,也可以用「excel」來標記它。 – user1934428