Mantistbt system exports excel as XML, and CSV Chinese garbled problem solved

Source: Internet
Author: User

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.