Converting Excel.Range to ExcelReference including SheetId #696
Replies: 2 comments
-
Looks like I found a way to retrieve SheetId specifically, Excel.Range range;
var address = range.Address[true, true, Excel.XlReferenceStyle.xlA1, true,null];
var sheetName = rangeId[0..rangeId.LastIndexOf('!')];
var sheetRange = (ExcelRange)XlCall.Excel(XlCall.xlSheetId, sheetName);
var sheetId = sheetRange.SheetId; |
Beta Was this translation helpful? Give feedback.
-
I think your way is fine. There is a constructor of ExcelReference that takes the sheet name:
To get the name (with the workbook name) I guess you could also try something like |
Beta Was this translation helpful? Give feedback.
-
Hi,
I need to compare a large number of ExcelReference instances with a small number of Excel.Range objects, specifically if their SheetId match.
Is there a way how to get ExcelReference from Excel.Range?
Previously I was comparing their string representation (xlfReftext and Excel.Range.Address), but that stops working with renaming a sheet leading to all sorts of complications.
Beta Was this translation helpful? Give feedback.
All reactions