如何使excel解释CSV文件中的汉字

我从包含中文字符的unix shell脚本发送报告。

当我用纯文本编辑器打开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 blah-group@mycompany.com 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 } 

这是一个编码问题。 一个简单的解决方法是打开文件使用谷歌工作表,并保存为从谷歌表格CSV。

Windows中文操作系统使用GBK作为默认中文编码。 您应该下载excel的中文,并通过Option来设置编码。

所以你应该把它编码为GBK或GB18130

  • (1)下载Open Office(免费快速安装,比Ubuntu中的Cals具有更高的文件大小)。

  • (2)检测您的CSV编码。 只需使用Open Office打开您的csv,然后select一种显示您的中文字符的编码方法。

  • (3)根据您的操作系统将您的csv保存为正确的编码。 默认的Windows编码是中文的GBK,Ubuntu是UTF8。