Python uses xlwt length limit to report errors

Python uses xlwt to report an error string longer than 32767 characters

The xlwt module is used to write xlsx files in the project. Today, we encountered the error of string longer than 32767 characters. Through consulting the data, we found that excel cells support 32767 characters at most. Finally, we got two solutions xlsxwriter and openpyxl

At first, I used openpyxl to write Excel files. I found that if there are some special characters in the cell content, an openpyxl.utils.exceptions.illegalcharactererror error error will be thrown. I used pandas.to_Excel also throws the same error, indicating pandas.to_Excel also uses the openpyxl method by default. If special characters can be controlled manually, they can be processed by themselves. If not, they have to use the xlsxwriter method

Xlsxwriter is similar to xlwt. It truncates when the cell character size exceeds 32767, so no error will be reported

Similar Posts: