diff --git a/src/Spout/Writer/Exception/InvalidDataException.php b/src/Spout/Writer/Exception/InvalidDataException.php
new file mode 100644
index 0000000..a51c8e7
--- /dev/null
+++ b/src/Spout/Writer/Exception/InvalidDataException.php
@@ -0,0 +1,14 @@
+' . PHP_EOL;
- } else {
- if (is_numeric($cellValue)) {
+ switch(true) {
+ case gettype($cellValue) === 'integer':
+ case gettype($cellValue) === 'boolean':
+ case gettype($cellValue) === 'float':
+ case gettype($cellValue) === 'double':
$data .= '>' . $cellValue . '' . PHP_EOL;
- } else {
+ break;
+ case gettype($cellValue) === 'object' && method_exists($cellValue, '__toString'):
+ $cellValue = (string)$cellValue;
+ case gettype($cellValue) === 'string':
if ($this->shouldUseInlineStrings) {
$data .= ' t="inlineStr">' . $this->stringsEscaper->escape($cellValue) . '' . PHP_EOL;
} else {
$sharedStringId = $this->sharedStringsHelper->writeString($cellValue);
$data .= ' t="s">' . $sharedStringId . '' . PHP_EOL;
}
- }
+ break;
+ case empty($cellValue):
+ $data .= '/>' . PHP_EOL;
+ break;
+ default:
+ throw new InvalidDataException("Invalid data type " . gettype($cellValue));
}
$cellNumber++;