本文整理汇总了C#中Range.get_Value方法的典型用法代码示例。如果您正苦于以下问题:C# Range.get_Value方法的具体用法?C# Range.get_Value怎么用?C# Range.get_Value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Range
的用法示例。
在下文中一共展示了Range.get_Value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCellText
public static string GetCellText(Range cell)
{
string text = null;
if (cell != null)
{
text = cell.Text;
if (text.StartsWith("#"))
{
text = cell.get_Value();
}
}
return TrimCellText(text);
}
示例2: return
TryGetNonEmptyRange
(
Range range,
out Range usedRange
)
{
Debug.Assert(range != null);
usedRange = null;
if (range.Rows.Count == 1 && range.Columns.Count == 1)
{
// The code below fails for the single-cell case -- iFirstColumn
// ends up being greater than iLastColumn. Check the cell
// manually.
if (range.get_Value(Missing.Value) == null)
{
return (false);
}
usedRange = range;
return (true);
}
const String WildCard = "*";
Range oFirstRow = range.Find(WildCard,
range.Cells[range.Rows.Count, 1], XlFindLookIn.xlValues,
XlLookAt.xlPart, XlSearchOrder.xlByRows,
XlSearchDirection.xlNext, false, false, Missing.Value);
if (oFirstRow == null)
{
return (false);
}
Range oFirstColumn = range.Find(WildCard,
range.Cells[1, range.Columns.Count], XlFindLookIn.xlValues,
XlLookAt.xlPart, XlSearchOrder.xlByColumns,
XlSearchDirection.xlNext, false, false, Missing.Value);
Range oLastRow = range.Find(WildCard,
range.Cells[1, 1], XlFindLookIn.xlValues,
XlLookAt.xlPart, XlSearchOrder.xlByRows,
XlSearchDirection.xlPrevious, false, false, Missing.Value);
Range oLastColumn = range.Find(WildCard,
range.Cells[1, 1], XlFindLookIn.xlValues,
XlLookAt.xlPart, XlSearchOrder.xlByColumns,
XlSearchDirection.xlPrevious, false, false, Missing.Value);
Debug.Assert(oFirstColumn != null);
Debug.Assert(oLastRow != null);
Debug.Assert(oLastColumn != null);
Int32 iFirstRow = oFirstRow.Row;
Int32 iFirstColumn = oFirstColumn.Column;
Int32 iLastRow = oLastRow.Row;
Int32 iLastColumn = oLastColumn.Column;
Worksheet oWorksheet = range.Worksheet;
usedRange = (Range)oWorksheet.get_Range(
(Range)oWorksheet.Cells[iFirstRow, iFirstColumn],
(Range)oWorksheet.Cells[iLastRow, iLastColumn]
);
return (true);
}