Set Excel number format using xlcFormatNumber in xll

I am trying to set the cell number format, but calling xlcFormatNumber does not remove the cell number format as "General". I can successfully set the cell value using 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); 

I could not find documentation about using this command. Any help here would be greatly appreciated.

+4
source share
1 answer

Thanks to Simon Murphy for the answer: Smurf on the tables

 //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); 
+5
source

Source: https://habr.com/ru/post/1276738/


All Articles