Configuración del formato de número de Excel a través de xlcFormatNumber en un xll

StackOverflow https://stackoverflow.com/questions/70643

  •  09-06-2019
  •  | 
  •  

Pregunta

Estoy intentando configurar el formato del número de una celda, pero la llamada a xlcFormatNumber falla y el formato del número de celda es "General".Puedo establecer con éxito el valor de la celda usando xlSet.

XLOPER xRet;
XLOPER xRef;

//try to set the format of cell A1
xRef.xltype = xltypeSRef;
xRef.val.sref.count = 1;
xRef.val.sref.ref.rwFirst = 0;
xRef.val.sref.ref.rwLast = 0;
xRef.val.sref.ref.colFirst = 0;
xRef.val.sref.ref.colLast = 0;

XLOPER xFormat; 
xFormat.xltype = xltypeStr;
xFormat.val.str = "\4#.00"; //I've tried various formats

Excel4( xlcFormatNumber, &xRet, 2, (LPXLOPER)&xRef, (LPXLOPER)&xFormat);

No he logrado encontrar ninguna documentación sobre el uso de este comando.Cualquier ayuda aquí sería muy apreciada.

¿Fue útil?

Solución

Gracias a Simon Murphy por la respuesta: -Pitufo en hojas de cálculo

//It is necessary to select the cell to apply the formatting to
Excel4 (xlcSelect, 0, 1, &xRef);

//Then we apply the formatting
Excel4( xlcFormatNumber, 0, 1, &xFormat);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top