 <p>Upgrading comment to an answer;</p> <p>Seems you are using <code>HSSF</code> instead of <code>XSSF</code> for xlsx. Hence, though <a href="https://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFRichTextString.html" rel="nofollow"><code>HSSFRichTextString</code></a> is valid for an <code>HSSFCell</code>, you need <code>XSSFCell</code> instead and then set its value with <a href="https://poi.apache.org/apidocs/org/apache/poi/xssf/usermodel/XSSFRichTextString.html" rel="nofollow"><code>XSSFRichTextString</code></a>.</p>