natergj/excel4node

addDataValidation list dropdown not working when formula is string too long

Closed this issue · 1 comments

Hi everyone, i'm try to create excel file with dropdown list in specifics cells, but the excel file is corrupt.

image

image

image

I'm used this code:

ws.addDataValidation({
type: 'list',
showDropDown: true,
allowBlank: true,
sqref: 'H2:H3',
formulas: [sizeNames],
});

When the value of variable sizeNames = '2.5 Centímetros,3 Centímetros,5 Centímetros,10 Centímetros,11 Centímetros,12 Centímetros,13 Centímetros,14 Centímetros,15 Centímetros,16 Centímetros,17 Centímetros,18 Centímetros,19 Centímetros,20 Centímetros,21 Centímetros,22 Centímetros,23 Centímetros,24 Centímetros,25 Centímetros,26 Centímetros,27 Centímetros,28 Centímetros,29 Centímetros,30 Centímetros,31 Centímetros,32 Centímetros,33 Centímetros,34 Centímetros,35 Centímetros,36 Centímetros,37 Centímetros,38 Centímetros,39 Centímetros,40 Centímetros,45 Centímetros,50 Centímetros,55 Centímetros,60 Centímetros,80 Centímetros,85 Centímetros,90 Centímetros,95 Centímetros,100 Centímetros,105 Centímetros,110 Centímetros,115 Centímetros,30x140 Centímetros,40x160 Centímetros,50x50 Centímetros,80x80 Centímetros,90x90 Centímetros,110x110 Centímetros,110x180 Centímetros,120x160 Centímetros,31x25x20 Centímetros,36x23x20 Centímetros,38x30x31 Centímetros,41x30x10 Centímetros,41x30x16 Centímetros,42x30x68 Centímetros,43x31x10 Centímetros,45x33x24 Centímetros,45x34x11 Centímetros,46x40x10 Centímetros,49x39x12 Centímetros,49x39x14 Centímetros,50x39x14 Centímetros,55x44x34 centímetros,55x37x22 centímetros,56x36x23 centímetros,56x42x24 centímetros,56x43.5x23 centímetros,58x55x26 centímetros,61x43x20 centímetros,65x30x29 centímetros,66x48x26 centímetros,66x49x23 centímetros,66x50x25 centímetros,66x51x23 centímetros,66x51.5x24 centímetros,66x51.5x25 centímetros,67x34x29 centímetros,67x50x26 centímetros,70x52x26 centímetros,73x56x28 centímetros,74x55x24 centímetros,74x56x28 centímetros,74x58x25 centímetros,76x57x28 centímetros,76x59.5x26 centímetros,76x59.5x28 centímetros,80x40x38 centímetros,80x60x30 centímetros,81x61x25 centímetros,1 Plaza,1.5 Plazas,2 Plazas,Litera,Especial,0.9 x 2,00,1.05 x 2,00,1.35 x 2,00,1.50 x 2,00,1.60 x 2,00,1.80 x 2,00,2.00 x 2,00,Copa A,Copa B,Copa C,Copa D,Copa E,0.5 Litros,1 Litro,1.5 Litros,KIDS,2 Litros,ADULTO,2.8 Litros,3 Litros,4 Litros,5 Litros,6 Litros,7 Litros,8 Litros,9 Litros,10 Litros,11 Litros,12 Litros,1 Metro,1.5 Metros,7.5 Milílitros,10 Milílitros,15 Milílitros,20 Milílitros,25 Milílitros,30 Milílitros,40 Milílitros,50 Milílitros,75 Milílitros,100 Milílitros,125 Milílitros,150 Milílitros,175 Milílitros,200 Milílitros,250 Milílitros,280 Milílitros,300 Milílitros,320 Milílitros,360 Milílitros,400 Milílitros,500 Milílitros,1000 Milílitros,10 Milímetros,13 Milímetros,N°1,N°1 1/2,N°2,N°2 1/2,N°3,N°3 1/2,N°4,N°4 1/2,N°5,N°5 1/2,N°6,N°6 1/2,N°7,N°7 1/2,N°8,N°8 1/2,N°9,N°9 1/2,N°10,N°10 1/2,N°11,N°11 1/2,N°12,N°12 1/2,N°13,N°13 1/2,N°14,N°18,N°19,N°20,N°21,N°22,N°23,N°24,N°25,N°26,N°27,N°28,N°29,N°30,N°31,N°32,N°33,N°34,N°35,N°36,42 Centímetros,70 Centímetros,75 Centímetros,Copa DD,N°15,N°16,N°17,N°35 1/2,N°36 1/2,N°37,N°37 1/2,N°38,N°38 1/2,N°39,N°40,N°41,N°42,N°43,N°44,N°45,N°46,N°23/24,N°25/26,0.5 Onza,1 Onza,1.5 Onza,1.7 Onza,1.75 Onza,2.5 Onza,3.3 Onza,3.4 Onza,8.4 Onza,17 Onza,2 Piezas,3 Piezas,4 Piezas,5 Piezas,6 Piezas,7 Piezas,8 Piezas,9 Piezas,10 Piezas,11 Piezas,12 Piezas,13 Piezas,14 Piezas,15 Piezas,16 Piezas,17 Piezas,18 Piezas,19 Piezas,20 Piezas,24 Piezas,48 Piezas,60 Piezas,96 Piezas,112 Piezas,151 Piezas,175 Piezas,14 Pulgadas,14.5 Pulgadas,15 Pulgadas,15.5 Pulgadas,16 Pulgadas,16.5 Pulgadas,17 Pulgadas,17.5 Pulgadas,18 Pulgadas,18.5 Pulgadas,20 Pulgadas,21 Pulgadas,25 Pulgadas,27 Pulgadas,29 Pulgadas,30 Pulgadas,31 Pulgadas,32 Pulgadas,33 Pulgadas,34 Pulgadas,35 Pulgadas,36 Pulgadas,40 Pulgadas,41 Pulgadas,46 Pulgadas,50 Pulgadas,51 Pulgadas,53 Pulgadas,60 Pulgadas,61 Pulgadas,Extra Extra Small,Extra Small,Small,Medium,Large,Extra Large,Extra Extra Large,Única,Standard,00 Meses,0 Meses,3 Meses,6 Meses,9 Meses,12 Meses,1 Año,18 Meses,24 Meses,2 Años,3 Años,4 Años,5 Años,Talla 1,Talla 2,Talla 3,Talla 4,Talla 5,Talla 6,Talla 7,Talla 8,Talla 9,Talla 10,Talla 11,Talla 12,Talla 13,Talla 14,Talla 15,Talla 16,Talla 18,Talla 20,Talla 22,Talla 23,Talla 24,Talla 25,Talla 26,Talla 27,Talla 28,Talla 29,Talla 30,Talla 31,Talla 32,Talla 33,Talla 34,Talla 35,Talla 36,Talla 37,Talla 38,Talla 39,Talla 40,Talla 41,Talla 42,Talla 43,Talla 44,Talla 45,Talla 46,Talla 48,Talla 50,Talla 52,Talla 54,Talla 56,Talla 58,Talla 60,Talla 63,Talla 80,Talla 90,Talla 95,Talla 98,Talla 100,Talla 102,Talla 104,Talla 106,Talla 108,Talla 110,Talla 112,Talla 116,Talla A,Talla B,Talla 1/2,Talla 3/4,Talla 5/6A,Talla 5/8,Talla 6/7A,Talla 7/8A,Talla 8/10,Talla 9/11,..............'

The variable sizeNames is a long string for array of size of my database, when the count of size is more of 1000 records.

I'm convert the array to string with a map function and use the join(',') for concat in one string.

The documentation of list dropdown with formula is ['value1, value2'];

Is there a limit of values ​​in the formula field of the addDataValidation function?

I have other addDatavalidation with formula: ['Argentina,Perú,Brasil,China,Panamá,Bangladesh,Chile,Italia,India,Inglaterra,Pakistán']

With this Country Data is work!

image

But with the values of sizeNames (more than 1000 records) corrupts the excel file and delete the validations of dropdown list when the microsoft excel try open the file and repair this.

I'm try open the excel file on Google Sheets and it's work! But on Microsoft Office and Microsoft 365 not working!

Image when open with Google Sheets. It's works!

image

Any solution? I need help with this.

Environment:

  • OS: [Mac OS Catalina]
  • Node Version: [12.19.0]
  • excel4node Version: [1.7.2]

I'm solved. I write the lists of data in other sheet and reference data with the addDataValidation function with property formulas.

Example:

ws.addDataValidation({
type: 'list',
showDropdown: true,
allowBlank: true,
sqref: 'H2:H3',
formulas: ['=BASE!$A$1:$A$100'],
});