From 7ac37edfebebc9bee201fad001e2f2f8b780a9a8 Mon Sep 17 00:00:00 2001 From: Arnie97 Date: Sat, 31 Jul 2021 00:31:51 +0800 Subject: Fix data validation issues (#975) * Fix `SetDropList` to allow XML special characters * This closes #971, allow quotation marks in SetDropList() This patch included a XML entity mapping table instead of xml.EscapeText() to be fully compatible with Microsoft Excel. * This closes #972, allow more than 255 bytes of validation formulas This patch changed the string length calculation unit of data validation formulas from UTF-8 bytes to UTF-16 code units. * Add unit tests for SetDropList() * Fix: allow MaxFloat64 to be used in validation range 17 decimal significant digits should be more than enough to represent every IEEE-754 double-precision float number without losing precision, and numbers in this form will never reach the Excel limitation of 255 UTF-16 code units. --- errors.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'errors.go') diff --git a/errors.go b/errors.go index 4931198..6b32563 100644 --- a/errors.go +++ b/errors.go @@ -105,4 +105,10 @@ var ( ErrSheetIdx = errors.New("invalid worksheet index") // ErrGroupSheets defined the error message on group sheets. ErrGroupSheets = errors.New("group worksheet must contain an active worksheet") + // ErrDataValidationFormulaLenth defined the error message for receiving a + // data validation formula length that exceeds the limit. + ErrDataValidationFormulaLenth = errors.New("data validation must be 0-255 characters") + // ErrDataValidationRange defined the error message on set decimal range + // exceeds limit. + ErrDataValidationRange = errors.New("data validation range exceeds limit") ) -- cgit v1.2.1