Tablora

Tablora · Library

Preserve text that looks like a SpreadsheetML escape

Text like _x0041_ is an escape code inside XLSX files. The text-safe converter protects it so the cell shows _x0041_ rather than the letter A.

A pattern the XLSX format reserves

Inside an XLSX file, text can contain codes of the form _x followed by four hexadecimal digits and an underscore, such as _x0041_. A spreadsheet reading the file decodes each code into the character it stands for, so _x0041_ becomes the capital letter A and _x000D_ becomes a carriage return. That is useful for software, but a problem when a real value happens to look like a code, for instance a system identifier, a field name from a database or a log token.

The text-safe converter protects every such pattern before writing it. It adds the escape for the underscore in front, which tells the spreadsheet to show the following characters literally. This is a separate step from escaping ampersands and angle brackets for XML.

Only the exact form is affected: an underscore, x, four hexadecimal characters and a closing underscore. Something like _x41_, or _x0041 without the closing underscore, is ordinary text in the file and in the spreadsheet.

The _x0041_ example

The page example has one column named code with the value _x0041_. The expected cell text in the workbook is _x0041_, written as explicit text, so the spreadsheet sees neither a formula nor a number there. When you open tablora-table.xlsx, the cell shows the seven characters you entered, not the letter A.

Checking escape-like values

Escape patterns in other exports

Original synthetic example

Input
code _x0041_
Expected cell text
_x0041_
Cell storage
Explicit text, not a formula or numeric cell

Tools

Sources