From 37624cf990743cbe3fdac8121bd89b56de4bb504 Mon Sep 17 00:00:00 2001
From: Robbie <robert.campbell@concentra.co.uk>
Date: Mon, 20 Sep 2021 02:38:41 -0400
Subject: [PATCH] XLS review [ci skip]

- truncate XLS Label Strings to 255 chars (fixes #1341)
- read column hidden attribute (fixes #2117)
- dateNF for XLS (fixes #1693 fixes #2305)
---
 bits/76_xls.js       | 4 ++--
 bits/78_writebiff.js | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bits/76_xls.js b/bits/76_xls.js
index 884a88f..31937b4 100644
--- a/bits/76_xls.js
+++ b/bits/76_xls.js
@@ -87,7 +87,7 @@ function safe_format_xf(p/*:any*/, opts/*:ParseOpts*/, date1904/*:?boolean*/) {
 			}
 			else p.w = SSF._general(p.v);
 		}
-		else p.w = SSF.format(fmtid,p.v, {date1904:!!date1904});
+		else p.w = SSF.format(fmtid,p.v, {date1904:!!date1904, dateNF: opts && opts.dateNF});
 	} catch(e) { if(opts.WTF) throw e; }
 	if(opts.cellDates && fmtid && p.t == 'n' && SSF.is_date(SSF._table[fmtid] || String(fmtid))) {
 		var _d = SSF.parse_date_code(p.v); if(_d) { p.t = 'd'; p.v = new Date(_d.y, _d.m-1,_d.d,_d.H,_d.M,_d.S,_d.u); }
@@ -570,7 +570,7 @@ function parse_workbook(blob, options/*:ParseOpts*/)/*:Workbook*/ {
 				case 'ColInfo': {
 					if(!opts.cellStyles) break;
 					while(val.e >= val.s) {
-						colinfo[val.e--] = { width: val.w/256 };
+						colinfo[val.e--] = { width: val.w/256, level: (val.level || 0), hidden: !!(val.flags & 1) };
 						if(!seencol) { seencol = true; find_mdw_colw(val.w/256); }
 						process_col(colinfo[val.e+1]);
 					}
diff --git a/bits/78_writebiff.js b/bits/78_writebiff.js
index d761cae..0344c63 100644
--- a/bits/78_writebiff.js
+++ b/bits/78_writebiff.js
@@ -69,7 +69,7 @@ function write_ws_biff2_cell(ba/*:BufArray*/, cell/*:Cell*/, R/*:number*/, C/*:n
 		case 'b': case 'e': write_biff_rec(ba, 0x0005, write_BIFF2BERR(R, C, cell.v, cell.t)); return;
 		/* TODO: codepage, sst */
 		case 's': case 'str':
-			write_biff_rec(ba, 0x0004, write_BIFF2LABEL(R, C, cell.v));
+			write_biff_rec(ba, 0x0004, write_BIFF2LABEL(R, C, (cell.v||"").slice(0,255)));
 			return;
 	}
 	write_biff_rec(ba, 0x0001, write_BIFF2Cell(null, R, C));