[VtigerCRM] Vtiger 其他中文化問題解決
客戶郵寄匯出,匯出的Excel檔中中文顯示亂碼。
需要修改的檔:/modules/Accounts/MailerExport.php
改動非常簡單,第289行 修改成print iconv("UTF-8", "Big5", $content);
產品管理裡面匯出產品資訊,在匯出的Excel檔中中文同樣顯示亂碼。
需要修改的檔:/include/utils/export.php
207行,對輸出進行編碼轉換,修改為:echo iconv("UTF-8", "Big5", $header);
同樣230行,改為:echo iconv("UTF-8", "Big5", $line);
匯出報表為Excel檔,中文顯示亂碼。
需要修改的檔:/modules/Reports/CreateXL.php
51行,改為:$worksheet->write(0, $count, iconv("UTF-8", "Big5", $key) , $header);
62行,改為:$worksheet->write($key+1, $dcount, iconv("UTF-8", "Big5", $value));
針對資料匯入時,即使 csv 檔轉為 utf-8 也會有中文字無法出現的問題,解決方式:
1. 不改程式:在所有中文資料欄位前加入一個英數字,待匯入後再手動修正。
2. 修改程式:可以直接匯入 excel 編輯的 big5 csv 檔
修改 \modules\Import\下的parse_utils.php
尋找程式碼:
function parse_import($file_name,$delimiter,$max_lines,$has_header)
在這段之前加
程式碼:
function translateCharset($string, $fromCharset, $toCharset='UTF-8') {
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($string, $toCharset, $fromCharset);
} elseif(function_exists('iconv')) { // iconv is flakey
return iconv($fromCharset, $toCharset, $string);
} else {
return $string;
} // end else clause
}
尋找程式碼:
// got no rows
if ( count($rows) == 0)
{
return -3;
}
接在後面加(共有2處都要加)
程式碼:
else
{
//// tw: bug 6712 - need to translate to UTF-8
foreach($rows as $rowKey => $row)
{
foreach($row as $k => $v) {
$row[$k] = translateCharset($v, 'BIG5');
}
$rows[$rowKey] = $row;
}
}
Thanks, this is really helpful
回覆刪除您好!請問一下處理中文資料匯入的部份,vTiger 5.4 與 6.0 beta 還是有您文中所說的中文字無法出現的問題,但是您文中所提及的 \modules\Import\parse_utils.php 我在檔案內都沒有找到,不曉得在這兩個版本有解法嗎?
回覆刪除感謝您無私的分享 vTiger 的使用經驗!
這是兩年前討論5.0.4的中文化經驗(不太可考),請參考5.4.0的經驗分享 http://summer10920.blogspot.tw/p/vtiger-crm.html
刪除另外6.0Beta我還沒碰過,因為官方還沒發布5.4.0 update to 6.0的更新包。也沒有工作機會讓我架一個6.0來玩
查此篇 http://summer10920.blogspot.tw/2012/11/vtiger_27.html
刪除調整報表轉Excel的亂碼問題