How to get the Excel "Cell Reference" for a cell

Product: WebViewer SpreadSheet Editor

Product Version: 11.7.1

I am evaluating the WebViewer SpreadSheet Editor. So far, integrating the WebViewer has gone very well. I am working with events, specifically the “SELECTION_CHANGED” event.

With the Cell object, is there a way to get the Excel “Cell Reference”?

I’m looking for ‘Sheet 1’!B4

So far I can’t see how to achieve this using the WebViewer SpreadSheet Editor.

Thanks!
-Brian

1 Like

Hello, I’m AiRon, an automated tech support bot :robot:
While you wait for one of our customer support representatives, I can help you with your question.


To obtain the Excel “Cell Reference” like ‘Sheet 1’!B4 in the WebViewer Spreadsheet Editor, you need to utilize the provided APIs to capture the selection and then format it accordingly.

Some things you can try:

  • Listen to the “SELECTION_CHANGED” event to determine when a cell selection changes.

  • Retrieve the selected cell’s row and column indices from the event data.

  • Convert these indices to a standard Excel cell reference format (e.g., column index to letter and row index to number).

  • Extract the sheet name from the current context to complete the reference.



Here are some resources that might help you:


Hopefully, this helps you solve your problem while you wait for a human to get back to you.

1 Like

Hi there,

While we do not have a direct API to get the sheet/cell information combination,

You can use the activeSheetChanged event to get the current active sheet and use the getSelectedCells method to get current cell information.

Best regards,
Kevin

1 Like

Thank you @kkim .
For getting the “C12” cell reference notation, it looks like the API provides the index (position)
Do I then have to create my own mapping to translate a Column Position of “2” to a Column letter of “C” (assuming a 0-based index)?

Thanks again,
-Brian

1 Like

Hi there,

If you already know the position - row/column, then you can use the Sheet’s getCellAt API:

Best regards,
Kevin

1 Like

Sorry if I was unclear, @kkim .

I have the cell through the event.
I can also get the active sheet.

What I want to do is get the Excel “Cell Reference” (or at least that’s what I’ve heard it called)


From your showcase, if I click on cell D8, I see in the function bar Calculations!G9

THAT is what I am trying to get when a cell is clicked.
I think what I’m missing is how to convert the column to a letter, like you do in the formula

1 Like

Hi there,

Thank you for your response,

We current do not have a public API available to translate the index to a Cell column alphabet letter.

You are able to get the rowIndex & columnIndex of a cell via the Cell class, but you will need to translate that numeric column index to its column letter via a utility function, i.e.

// works for the first 26 alphabet characters
function columnNumberToLetter(columnIndex) {
  let letter = '';
  let num = parseInt(columnIndex, 10) + 1; // Excel columns are 1-based

  while (num > 0) {
    let remainder = (num - 1) % 26;
    letter = String.fromCharCode(65 + remainder) + letter;
    num = Math.floor((num - 1) / 26);
  }

  return letter;
}

best regards,
Kevin

1 Like