none
xlSet on merged cells RRS feed

  • Question

  • I have a question about xlSet command on merged cells.
    http://msdn.microsoft.com/en-us/library/bb687826
    Excel12(xlSet, LPXLOPER12 pxRes, 2, LPXLOPER12 pxReference, LPXLOPER pxValue);
    Suppose,
    B2 and C2 are merged. 
    pxReference are xltypeSRef to A1:B2.
    pxValue are xltypeMulti array contains four string elements.

     |A|B|C|
    ---------
    1|*|*|
    ---------
    2|*| * |
    ---------

    Then, I executed the above Excel12 command, the return code was 32(command failed).
    Is there any method to set the array of elements into a rectangle range that contains merged cell partially?
    Friday, December 5, 2014 8:57 PM

Answers

  • Hi Chutorotor,

    You could not select range A1:B2 since the B2 and C2 are merged.

    As a workaround, you could select range A1:C2 and reserve the value of C1.

    Here is the code for your reference:

    __declspec(dllexport) int WINAPI fSetCell(void)
    {
    	XLOPER12 xRef, xValue, xRes;
    
    	xRef.xltype = xltypeSRef;
    	xRef.val.sref.count = 1;
    	xRef.val.sref.ref.rwFirst = 0;
    	xRef.val.sref.ref.rwLast = 1;
    	xRef.val.sref.ref.colFirst = 0;
    	xRef.val.sref.ref.colLast = 2;
    
    	// reserve the value of C1
    	Excel12(xlfValue, &xRes, 1, TempActiveRef12(0, 0, 2, 2));
    
    	XLOPER12 data[2][3] = {
    			{ *TempInt12(11), *TempInt12(23), xRes},
    			{ *TempInt12(4), *TempInt12(5), *TempMissing12()}
    	};
    
    	xValue.xltype = xltypeMulti;
    
    	xValue.val.array.rows = 2;
    
    	xValue.val.array.columns = 3;
    
    	xValue.val.array.lparray = &data[0][0];
    
    	int ret = Excel12(xlSet, 0, 2, (LPXLOPER12)&xRef, (LPXLOPER12)&xValue);
    
    	return 1;
    }

    Regards,

    Jeffrey


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Tuesday, December 9, 2014 6:00 AM
    Moderator

All replies

  • Any comments would be appreciated.
    Saturday, December 6, 2014 6:18 PM
  • Hi Chutorotoro,

    As far as I know, you can only unmerge the cells, then execute this function, merge the cells back finally. I think it's by design, very similar to pasting the value of a range to another which has a merged cell.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 8, 2014 7:29 AM
    Moderator
  • Hi Chutorotor,

    You could not select range A1:B2 since the B2 and C2 are merged.

    As a workaround, you could select range A1:C2 and reserve the value of C1.

    Here is the code for your reference:

    __declspec(dllexport) int WINAPI fSetCell(void)
    {
    	XLOPER12 xRef, xValue, xRes;
    
    	xRef.xltype = xltypeSRef;
    	xRef.val.sref.count = 1;
    	xRef.val.sref.ref.rwFirst = 0;
    	xRef.val.sref.ref.rwLast = 1;
    	xRef.val.sref.ref.colFirst = 0;
    	xRef.val.sref.ref.colLast = 2;
    
    	// reserve the value of C1
    	Excel12(xlfValue, &xRes, 1, TempActiveRef12(0, 0, 2, 2));
    
    	XLOPER12 data[2][3] = {
    			{ *TempInt12(11), *TempInt12(23), xRes},
    			{ *TempInt12(4), *TempInt12(5), *TempMissing12()}
    	};
    
    	xValue.xltype = xltypeMulti;
    
    	xValue.val.array.rows = 2;
    
    	xValue.val.array.columns = 3;
    
    	xValue.val.array.lparray = &data[0][0];
    
    	int ret = Excel12(xlSet, 0, 2, (LPXLOPER12)&xRef, (LPXLOPER12)&xValue);
    
    	return 1;
    }

    Regards,

    Jeffrey


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Tuesday, December 9, 2014 6:00 AM
    Moderator