PhpSpreadsheet Issue With Vertical Tabs (0x0B)

This article is about fixing the following error:

Failed to load path_to_project/storage/framework/laravel-excel/laravel-excel-eTdm3TlUf1neh8QbolfXmodtigO50x3x.html as a DOM Document

Recently I caught a bug where PHP excel parser (PhpSpreadsheet) was failing when parsing some rows fetched from the database. With a series of trial and error tests, I found the row that was causing the failure.

So, I copied the sentence in Sublime Text and saw that there was a hex character (0x0b) in the sentence. This character is known as a “Vertical Space” and is visually invisible in most editors. I couldn’t see this character in Mysql Workbench so I copied the whole row in Sublime text and saw the hex representation of this character. Below are some other representations of this character:

  • 0x0b
  • “\v”

To fix the issue, I ran the following SQL query to find all sentences containing this character and then removed them from the database:

SELECT text FROM messages WHERE text LIKE CONCAT('%',0x0b,'%');

It’s a good practice to filter your inputs and make sure you’re not storing unwanted characters like these in the database, they might bite you one day!