Код: Выделить всё
//if there is a cell reference to another worksheet
if (strI == "!")
{
int sheetEnd = i - 1;
strSheet = strFormText.Substring(p1, sheetEnd - p1 + 1);
if (strSheet.Contains(" "))
strSheet = "'" + strSheet + "'";
strSheet += "!";
p1 = i + 1;
i++;
goto STARTLOOP;
}
...
...
...
// check if string is an actual cell reference
try
{
strCell = strSheet + strCell;
ExcelReference refCell = (ExcelReference)Excel(xlfIndirect, strCell, true);
object val = refCell.GetValue();
string format = (string)Excel(xlfGetCell, 7, refCell); // Get cell number format
strCell = (string)Excel(xlfText, val, format); // Format value as displayed in Excel
}
// ...if strCell is a number (OR) if cell is empty
catch (InvalidCastException)
{
if (objCell is ExcelEmpty) strCell = "0";
else if (ToolsArgs.ChkStringDouble(strCell)) { }
else if (strList.Contains(strH)) strCell = "";
}
catch { strFormula = "CatchAll 3"; }
< /code>
Для примера ...
Cell D68 на активном рабочем листе ("лист1") содержит формулу < /p>
=Sheet2!D27+Sheet2!D28+Sheet2!D29+Sheet2!D30
Но в настоящее время код не может обрабатывать и искать это значение на другом рабочем листе и либо сбои, либо бросает ошибку.>
Подробнее здесь: https://stackoverflow.com/questions/796 ... -worksheet
Мобильная версия