I found that the methods mentioned in other answers are either unavailable on the online website or too complicated to operate. Let me recommend the latest available method I found. It supports removing line numbers and controlling fonts.
It can solve the problem of code display effect in Word.
example: