Home >Backend Development >PHP Tutorial >Data loss problem when importing Excel database (sometimes good or bad)
Recently, I have been developing the excel import resume (excel file) function. When importing excel, the data inserted into the database often appears to be incomplete (only part of the data), so I print the obtained data in the excel table before inserting,
It was found that what was printed was a rich text object (composed of unformatted text, control words, and control symbols. For example, the fonts in excel include Song Dynasty, Kaili, and other font formats). This is the root cause of the insertion failure.
Solution: Type cast to string
Before change:
After change:
The problem is solved,,, it’s that simple, I hope it can help you who are troubled!
The above has introduced the data loss problem (sometimes good and sometimes bad) when importing Excel into the database, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.