I have a string large than 255 characters. i can write file success on xlsx type.
How can i write on xls.
when i save xlsx as xls on windows, i can get the content larger than 255 success.
Hi,
I ran into the same issue when saving a longer string (>450 characters) in a cell with BIFF8. The string was truncated to 255 characters even though BIFF8 should support up to 32767 characters per cell (verified with manually saving a BIFF8 file with Excel).
When saving as XLSX the issue is not present and the full string is saved into the cell.
Does anyone have an idea how to solve this or a workaround?
Thanks,
Stefan
same problem here, please contacts me if you find a solution. Many thx
Thanks for sharing! For BIFF8 XLS an inline Label Record (record type 0x0204) is used for storing strings. The file itself is storing the full string, and you can verify by generating a new file, reading the generated file and inspecting the cell:
// var XLSX = require("xlsx"); // for nodejs
var wb = XLSX.utils.book_new();
var ws = XLSX.utils.aoa_to_sheet([
["a".repeat(1000)] // "aaa...aaa" 1000 characters
]);
XLSX.utils.book_append_sheet(wb, ws, "aaa");
var data = XLSX.write(wb, {type:"binary", bookType:"xls"});
if(data.charCodeAt(0) != 0xD0) throw new Error("File is not a valid BIFF8 XLS")
var newwb = XLSX.read(data, {type:"binary"});
console.log(newwb.Sheets["aaa"]["A1"].v.length); // prints 1000
It seems Excel itself is truncating to 255 characters, which means we'll have to go back and use the SST instead.
Indeed, I run into the same issue today.
thanks to @sstadlberger comments I was able to switch from *.xls to *.xlsx and avoid the issue.
use require('xlsx/dist/xlsx.full.min.js') instead of require(''xlsx/dist/xlsx.min.js')
'.xlsx' instead of '.xls'
Most helpful comment
Indeed, I run into the same issue today.
thanks to @sstadlberger comments I was able to switch from *.xls to *.xlsx and avoid the issue.