Inserting Links into Worksheet Cells

 

Version Info

Minimum Origin Version Required: Origin91 SR0

Cell Link Notation

Cell link notation has the following syntax:

Object://ocfilename:ocfuncname|displaytext|extrainfo
  • ocfilename is a valid Origin C file with .c or .cpp suffix, and put under OriginInstallFolder\OriginC\Originlab.
  • ocfuncname is the callback function name, with prototype like int object_callback(string& label, string& strExtraInfo);
  • displaytext is the label to be displayed in the cell and will be passed to the callback as the first argument, and it can be modified by the callback.
  • extrainfo is a string contains any user information which will be passed to the argument as the second argument, and it can be modified by the callback.

Examples

This example below shows how to use cell link notation.

  • Copy the notation: "OBJECT://UserLink.c:UserCallback|Go to Result Sheet|Result sheet" to any cell of a workbook.
  • create a new OC file UserLink.c and put under \OriginC\Originlab, with content below:
int UserCallback(string& strLabel, string& strExtra)
{
        strExtra ="Result Sheet";
        strLabel = "Go to Result sheet";
        
        // Access the workbook named "Book1"
        WorksheetPage wksPage("Book1");
 
        // Add a new sheet to the workbook
        int index = wksPage.AddLayer(strExtra);
        
        // Access the new worksheet
        Worksheet wksNew = wksPage.Layers(index); 
        
        // Set the new worksheet to be active
        set_active_layer(wksNew);
    
        return 0;
        
}
  • Go back to the cell with link notation, then click it.