إعداد Excel تنسيق الرقم عبر xlcFormatNumber في xll

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

  •  09-06-2019
  •  | 
  •  

سؤال

أنا أحاول أن تعيين تنسيق الرقم الخليوي ولكن الدعوة إلى xlcFormatNumber فشل في ترك خلية تنسيق الأرقام "العامة".يمكنني بنجاح تعيين قيمة الخلية باستخدام 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);

لم تمكن من العثور على أي وثائق بشأن استخدام هذا الأمر.أي مساعدة هنا سيكون موضع تقدير كبير.

هل كانت مفيدة؟

المحلول

شكرا سيمون ميرفي الجواب:- الحوت على جداول البيانات

//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);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top