Definição de Excel Formato de Número através de xlcFormatNumber em um xll

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

  •  09-06-2019
  •  | 
  •  

Pergunta

Eu estou tentando definir o formato dos números de uma célula, mas a chamada para xlcFormatNumber falha, deixando a célula formato de número como "Geral".Eu com êxito pode definir o valor da célula 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);

Eu ainda não conseguiram encontrar qualquer documentação sobre o uso deste comando.Qualquer ajuda seria muito apreciada.

Foi útil?

Solução

Graças a Simon Murphy para a resposta: Smurf em Planilhas

//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 em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top