VtigerCRM5.4.0数据导出导入csv乱码修复
来源:互联网 发布:什么叫数据铁笼 编辑:程序博客网 时间:2024/06/06 05:55
在Smarty/templates/ImportStep1.tpl中的第99行插入<option value=”GBK”>GBK</option>
<select name="format" class="small">
<!-- value must be a known format for mb_convert_encoding() -->
<option value="GBK">GBK</option> // <<插入一行
<option value="ISO-8859-1">ISO-8859-1</option>
<option value="UTF-8">UTF-8</option>
</select>
再修改modules/Import/resources/Utils.php中的第21行
修改为:static $supportedFileEncoding = array('UTF-8'=>'UTF-8','ISO-8859-1'=>'ISO-8859-1');
添加了GBK的数组,smarty再引用这个的数组的值。static $supportedFileEncoding = array('UTF-8'=>'UTF-8','GBK'=>'GBK','ISO-8859-1'=>'ISO-8859-1');
原理说明:
导入时的程序执行的是先用了\Smarty\templates\modules\Import\ImportBasic.tpl 然后再引入不同的tpl文件
<tr> <td class="leftFormBorder1" width="60%" valign="top">
{include file='modules/Import/Import_Step1.tpl'} //第1步 </td>
<td class="leftFormBorder1" width="40%" valign="top"> {include file='modules/Import/Import_Step2.tpl'} //第2步 </td> </tr>
<tr> <td class="leftFormBorder1" colspan="2" valign="top"> {include file='modules/Import/Import_Step3.tpl'} //第3步 </td> </tr>
<tr> <td align="right" colspan="2"> {include file='modules/Import/Import_Basic_Buttons.tpl'} </td> </tr>
再调用了modules/Import/Import_Step2.tpl 第34行代码如下:
<select name="file_encoding" id="file_encoding" class="small"> {foreach key=_FILE_ENCODING item=_FILE_ENCODING_LABEL from=$SUPPORTED_FILE_ENCODING} <option value="{$_FILE_ENCODING}">{$_FILE_ENCODING_LABEL|@getTranslatedString:$MODULE}</option> <!--这里是数据类型--> {/foreach}</select>
如果需要将一个Excel表格导入,要注意以下几个步骤:
另存为CSV文件后,必须的格式要如下(表列值必须是双引号),然后中间有逗号分隔。"姓名","性别","电话","手机""张三","男","84577487","13878902345""李四","女","25878456","13978581278"
注意:如果用导出的客户资料csv文件为模版,用Excel来编辑客户资料用来导入,则必须要经过处理,
因为用Excel保存完csv文件之后,用UE打开后每列值是没有双引号的,如下:
姓名,性别,电话,手机张三,男,84577487,13878902345李四,女,25878456,13978581278
处理方法:
1、用UE打开,替换,为","
2、上传到linux系统,用vim编辑,在行首和行尾分别加入"
:%s/^/“/g (在每行行首添加")
:%s/$/"/g (在每行行尾添加")
然后就可以成功将中文导入了。
导出数据文件CSV中文乱码修正:
修改include/utils/export.php中的第208,232和240行
echo iconv("UTF-8", "GBK", $header); //原来: echo $header;
echo iconv("UTF-8", "gbk", $line); //原来: echo $line; } $log->debug("Exiting export method ..."); return true; }
header("Content-Disposition:attachment;filename={$_REQUEST['module']}.csv"); header("Content-Type:text/csv;charset=gbk"); //原来: header("Content-Type:text/csv;charset=UTF-8"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" ); header("Cache-Control: post-check=0, pre-check=0", false );
- VtigerCRM5.4.0数据导出导入csv乱码修复
- VtigerCRM5.4.0数据导出导入csv乱码修复
- MySQL CSV 数据导入导出
- mongodb 数据备份与还原操作--备份 还原 导出 导入:CSV,JSON,BOSN,解决中文乱码
- GlacialList数据导入导出(txt与CSV)
- MySQL数据导入导出csv文件命令
- 导入导出mysql表数据到csv
- php导入导出CSV格式的数据
- csv格式导入导出mysql数据
- python导出数据至CSV中文乱码
- Mysql 导入导出csv 中文乱码问题的解决方法
- 导出CSV数据中文乱码和文件名乱码
- mysql 导入导出 csv
- php导入、导出csv
- csv文件导入导出
- csv文件导入导出
- MySQL导入、导出CSV
- postgresql 导入导出 csv
- _max和hash表的关系及调整
- Sigslot介绍
- JDK 环境变量设置
- SQLServer的数据类型
- Excel导入数据到QC
- VtigerCRM5.4.0数据导出导入csv乱码修复
- epoll源码分析---sys_epoll_create()函数
- ip_conntrack: table full, dropping packet.
- Retrying requests using request-retry handlers
- QMetaObject::connectSlotsByName: No matching signal for
- Oracle查询表名的步骤简介
- VS2010中如何更新项目名称且同步更新磁盘文件夹?
- mpi编程入门之helloworld
- Uml 与 Rational Rose( 类图 )