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.
Hello, I’m AiRon, an automated tech support bot 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.
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)?
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;
}