Spreadsheet Editor get Sheet from Name and get Cell from DisplayValue

Good evening and Happy Friday!

I am in the works of evaluating the Spreadsheet Editor.
When a user clicks a cell in a sheet, I am capturing the Sheet’s name and the Cell’s “Display Value” (from the event).

What I now attempting to do is reverse that process, where I have that list of `Sheet Name`!<Cell DisplayValue> (ie - `Sheet 1`!A13)

when someone clicks that from my list, I want to be able to activate cell A13 in Sheet 1.

I think I can figure out the row & cell index values from the Cell Display value, but I can’t see a way to get the sheet index from the sheet name (or set an active sheet using the sheet name).

  1. is there a way to set an Active Sheet using the Sheet Name instead of the Sheet Index?
  2. is there a way to set an Active Cell using the Display Value, rather than the row index & cell index?

Thank you!
-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 achieve the functionality of selecting a sheet and cell based on their names and display values, you can use the Apryse Spreadsheet Editor APIs to interact with sheets and cells programmatically.

Some things you can try:

  • Use the Workbook.getSheet API to retrieve a sheet by its name. This allows you to activate a sheet without needing its index.

  • To activate a cell using its display value, you will need to convert the display value (e.g., A13) into row and column indices. Typically, this involves translating the column letter(s) to a zero-based index and parsing the row number.

  • Once you have the sheet and the indices, you can set the active cell using the appropriate API calls within the Spreadsheet Editor.




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

Hello Brian,

Thank you for contacting WebViewer Forums.

The setActiveSheet() method only takes in an number so using a sheet name may not be possible.

const workbook = spreadsheetEditorManager.getWorkbook();
workbook.setActiveSheet(index);

To get the active cell using the display value, you may need to create a custom function that converts the Row (letters) to a number and Column (number-1), return those values and then call getCellAt().

Regards,
Luke

1 Like

Thank you, Luke.
I see how I can set the active sheet.

Is there a way that I can programmatically set the active cell?
I can’t figure out how to do that.

I can see how I can get a cell, but I don’t see how I can set the active cell.

Thanks,
-Brian

1 Like

Hello Brian,

Thank you for your reply.

Currently we do not have a set cell selection type of API however if this is something that can benefit you, I would be happy to submit a feature request! If so, we would be interested to know:

  • What is the workflow that you would use the requested feature in?
  • Why is the feature valuable to you and your users?

Regards,
Luke

1 Like

Thanks @luke.dam .

I was actually able to get it to work

            let parsedCellRange = this.wvInstance.Core.SpreadsheetEditor.CellRange.parseRangeString(cell);
            this.spreadsheetEditorDocument.selectCellRange(new this.wvInstance.Core.SpreadsheetEditor.CellRange({
                firstRow: parsedCellRange.firstRow,
                firstColumn: parsedCellRange.firstColumn,
                lastRow: parsedCellRange.lastRow,
                lastColumn: parsedCellRange.lastColumn
            }));

My call to parseRangeString returns an object that is rejected by selectCellRange. I think the selectCellRange method is doing an object type check, where parseRangeString returns an any object, even with the same properties aligning.

-Brian

1 Like