[英]How to find the value of a cell adjacent to the current cell C# + Excel
[英]How to find the defined name for a specific excel cell in c#
我試圖在 C# 中的 Excel 文件中找到單元格的定義名稱,我試圖找到該值並且我成功了,但我無法找到該名稱。 這是我成功找到值的代碼:
Application application = new Application();
Workbook workBook = application.Workbooks.Open(requestSheetPath, 0, true, 5, "", "", true, XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
Worksheet workSheet = (Worksheet)workBook.Worksheets.get_Item(sheet);
Range range = workSheet.UsedRange;
if (range.Cells[column, row] != null && range.Cells[column, row].Value2 != null)
return range.Cells[column, row].Value2.ToString();
如何找到定義的名稱?
你會想要使用 Excel.Worksheet.Names
foreach (Excel.Worksheet sheet in wb.Sheets) {
foreach (Excel.Range range in sheet.Names) {
// this is the named ranges
}
}
您可以查看此答案以獲取更多信息
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.