none
C-api and sheet ids RRS feed

  • Question

  • Hello,

    in the xlcall.h for the c-pi there's  the type IDSHEET with is used for xlopers of xltypeRef.

    struct 
    {
    	XLMREF *lpmref;
    	IDSHEET idSheet;
    } mref;	/* xltypeRef */

    a) Is idSheet unique for every sheet across all open workbooks ?

    b) Stay the value of idSheet if you rename the sheet ?

    c) Stay the value of idSheet if save the workbook under a different Name (saveas) ?

    tia

      Hendrik Schmieder

    Tuesday, July 29, 2014 9:47 AM

Answers

  • Hi Hendrik,

    I’m not able to find a detail document to answer your questions, so I take a few tests and here is my test result:

    Is idSheet unique for every sheet across all open workbooks?

    Yes, the idSheet will be unique for every sheet.

    b) Stay the value of idSheet if you rename the sheet?

    Yes, the idSheet will not be changed with sheet name.

    c) Stay the value of idSheet if save the workbook under a different Name (saveas)?

    No, based on my test, the idSheet is a runtime value, when you close the workbook and open it again, a new idSheet will be assigned.

    Test Code:

    __declspec(dllexport) LPXLOPER12 WINAPI TestFunc(LPXLOPER12 x)
    {
    	static XLOPER12 xResult;
    
    	XLOPER12 xSheetName, xRes;
    
    	Excel12(xlfCaller, &xRes, 0);
    
    	Excel12(xlSheetNm, &xSheetName, 1, (LPXLOPER12)&xRes);
    
    	Excel12(xlSheetId, &xRes, 1, (LPXLOPER12)&xSheetName);
    
    	Excel12(xlFree, 0, 1, (LPXLOPER12)&xSheetName);
    	Excel12(xlFree, 0, 1, (LPXLOPER12)&xRes);
    
    	return TempNum12(xRes.val.mref.idSheet);
    }

    Hope it will help.

    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.

    Wednesday, July 30, 2014 5:51 AM
    Moderator
  • Hi Hendrik,

    I don't know what’s the algorithm is used to generate the SheetId, but the sheet ID of a named sheet is in order to construct external references, it is not sequenced and I don’t think it will be re-used.

    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.

    Friday, August 1, 2014 8:25 AM
    Moderator

All replies

  • Hi Hendrik,

    I’m not able to find a detail document to answer your questions, so I take a few tests and here is my test result:

    Is idSheet unique for every sheet across all open workbooks?

    Yes, the idSheet will be unique for every sheet.

    b) Stay the value of idSheet if you rename the sheet?

    Yes, the idSheet will not be changed with sheet name.

    c) Stay the value of idSheet if save the workbook under a different Name (saveas)?

    No, based on my test, the idSheet is a runtime value, when you close the workbook and open it again, a new idSheet will be assigned.

    Test Code:

    __declspec(dllexport) LPXLOPER12 WINAPI TestFunc(LPXLOPER12 x)
    {
    	static XLOPER12 xResult;
    
    	XLOPER12 xSheetName, xRes;
    
    	Excel12(xlfCaller, &xRes, 0);
    
    	Excel12(xlSheetNm, &xSheetName, 1, (LPXLOPER12)&xRes);
    
    	Excel12(xlSheetId, &xRes, 1, (LPXLOPER12)&xSheetName);
    
    	Excel12(xlFree, 0, 1, (LPXLOPER12)&xSheetName);
    	Excel12(xlFree, 0, 1, (LPXLOPER12)&xRes);
    
    	return TempNum12(xRes.val.mref.idSheet);
    }

    Hope it will help.

    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.

    Wednesday, July 30, 2014 5:51 AM
    Moderator
  • Thanks for the answers.

    A note to c:

    Maybe a wasn't precise enough.

    c) Stay the value of idSheet if save the workbook under a different Name (saveas) until the worbokk is closed?

    And now there's a 4th one.

    d) Does a running Excel reuse sheetids ?

        Consider following Scenario:

       You open workbook wb1. first sheet get sheetid id1. Now you Close wb1 and open workbook wb2.

       Can it be that one sheet of wb2 get the shettid id1.

    tia

      Hendrik   Schmieder

       

    Wednesday, July 30, 2014 7:35 AM
  • Hi Hendrik,

    I don't know what’s the algorithm is used to generate the SheetId, but the sheet ID of a named sheet is in order to construct external references, it is not sequenced and I don’t think it will be re-used.

    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.

    Friday, August 1, 2014 8:25 AM
    Moderator