export-csv-xls-charset-problem

Questionsexport-csv-xls-charset-problem
FARRO asked 11 months ago

Hello! I don\’t know how to solve the problem. I have a table with Cyrillic data in it. https://i.imgur.com/eudomYh.jpg When using all types of exports to xls and csv, I get a file with incorrect encoding if I open it in Excel https://i.imgur.com/7F1am5t.jpg Maybe there is a way to get a valid file after exporting? I tried to translate the database to cp1251 and windows-1251 and change the encoding in the configuration file, but the result was the same. The project itself has the following encoding // database charset define(\”PHPGRID_DBCHARSET\”, \”utf8\”); Database utf8mb4_general_ci

2 Answers
Abu Ghufran Staff answered 10 months ago

Please try after modifying you table collation to ‘utf8_general_ci’. I’ve verified the excel export with following sample data: Зарегистрируйтесь сейчас на Десятую Международную Конференцию

e.g.

CREATE TABLE `invheader` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`invdate` DATE NOT NULL,
`client_id` INT(11) NOT NULL,
`amount` DECIMAL(10,2) NOT NULL DEFAULT ‘0.00’,
`tax` DECIMAL(10,2) NOT NULL DEFAULT ‘0.00’,
`total` DECIMAL(10,2) NOT NULL DEFAULT ‘0.00’,
`note` TEXT NULL DEFAULT NULL COLLATE ‘utf8_general_ci’,
`closed` CHAR(3) NULL DEFAULT ‘No’ COLLATE ‘utf8_general_ci’,
`ship_via` CHAR(255) NULL DEFAULT NULL COLLATE ‘utf8_general_ci’,
PRIMARY KEY (`id`) USING BTREE
)
COLLATE=’utf8_general_ci’
ENGINE=MyISAM
AUTO_INCREMENT=16;

 

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
FARRO replied 10 months ago

I made a sql query using your example and saved the php file in UTF-BOM and it worked. Works great with CSV. Maybe there is some trick to make the column separator a “;” character?

I don’t know if it’s related to the file or database encoding, but with xls and xlsx I couldn’t get a file that would open in Excel. Partial content error. Maybe you have encountered such an error and know what the problem may be?

Abu Ghufran Staff answered 10 months ago

I saw your other email and you said your database has utf8mb4 collation. Please verify if it’s the same for table and fields as well.

If issue does not solve, Please share your database schema (sql) with some test data to regenerate this case here. You can email me at [email protected]

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

8 + 3 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?