1. Problem Description
We deployed a mantisbt bug submission system. After the language is set to Chinese in config_inc.php, the interface is changed to a Chinese interface. However, in the problem column, we export the CSV file and we will find it garbled, the exported Excel file is suffixed with XML. Although it can be opened through the Excel software, the worksheet name is garbled (that is, the footer name under the Excel table ).
2. Specific analysis
We have searched the internet and found a similar solution. For more information, see this link. However, due to version changes, my solution is 1.2.11, which is currently the latest and cannot solve any problems, give up.
3. Solution
3.1 How to export an Excel file as an XML suffix
In the mantisbt directory, in the file excel_xml_export.php, we can see the following line:
header( 'Content-Disposition: attachment; filename="' . urlencode( file_clean_name( $t_export_title ) ) . '.xml"' ) ;
Therefore, change:
header( 'Content-Disposition: attachment; filename="' . urlencode(file_clean_name( $t_export_title ) ) . '.xls"' ) ;
This solves the problem of exporting Excel files with extensions in XML format. In fact, the mantisbt system is set to XML very correctly, because XML is a standard file data exchange mode, the differences in system encoding are avoided, but in Windows, it is still replaced by XLS.
3.2 solution to table footer file name garbled
The above only solves the suffix problem, but the injection script is still garbled.
See, I am libreoffice, the same as Ms.
After reading it, I did not find a path in the source code. Later I thought that I had used urlencode to convert and encrypt a simple password. Then I suddenly found this garbled code a bit similar, using the URL Decoding function, we found that it was the escape of the Chinese "Report", and our project was called a bug report. So we understood the solution and found it in excel_xml_export.php.
Find this Code:
Echo excel_get_header ($ t_export_title); changed to echo urldecode (excel_get_header ($ t_export_title ));
The problem is solved.
3.3 CVS file garbled
In fact, this problem can find the reason, if the Linux system is no problem, because this uses UTF-8 encoding, and Windows by default is GBK encoding. In Windows, the Excel file contains garbled characters. You only need to use Edit plus to view the code.