本文整理汇总了C#中Range.set_Value方法的典型用法代码示例。如果您正苦于以下问题:C# Range.set_Value方法的具体用法?C# Range.set_Value怎么用?C# Range.set_Value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Range
的用法示例。
在下文中一共展示了Range.set_Value方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MergeDuplicateEdges
//.........这里部分代码省略.........
// The key is a vertex name pair and the value is the one-based table
// row number of the first instance of the edge. If the edge worksheet
// contains these rows, for example:
//
// 1 X,Y
// 2 A,B
// 3 A,B
// 4 C,D
// 5 A,B
// 6 A,B
//
// then the dictionary will have three entries: one for X,Y, one for
// A,B, and one for C,D. The entry for X,Y will have a value of 1 (the
// one-based table row number of the first instance of X,Y), the entry
// for A,B will have a value of 2, and the entry for C,D will have a
// value of 4.
Dictionary<String, Int32> oUniqueEdges =
new Dictionary<String, Int32>();
// Loop through the table rows.
Int32 iRows = oVertex1NameData.Rows.Count;
for (Int32 iRowOneBased = 1; iRowOneBased <= iRows; iRowOneBased++)
{
String sVertex1Name, sVertex2Name;
if (
!ExcelUtil.TryGetNonEmptyStringFromCell(aoVertex1NameValues,
iRowOneBased, 1, out sVertex1Name)
||
!ExcelUtil.TryGetNonEmptyStringFromCell(aoVertex2NameValues,
iRowOneBased, 1, out sVertex2Name)
)
{
continue;
}
// Does the row already have an edge weight?
Double dInitialEdgeWeight = 1;
Object oInitialEdgeWeight = aoEdgeWeightValues[iRowOneBased, 1];
if (oInitialEdgeWeight != null && oInitialEdgeWeight is Double)
{
// Yes.
dInitialEdgeWeight = (Double)oInitialEdgeWeight;
}
else
{
// No. Set the initial edge weight.
aoEdgeWeightValues[iRowOneBased, 1] = 1.0;
}
// Has an instance of this edge already been found?
String sVertexNamePair = Edge.GetVertexNamePair(
sVertex1Name, sVertex2Name, bGraphIsDirected);
Int32 iFirstInstanceRowOneBased;
if ( oUniqueEdges.TryGetValue(
sVertexNamePair, out iFirstInstanceRowOneBased) )
{
// Yes. This row will need to be deleted. Mark it by nulling
// its edge weight.
aoEdgeWeightValues[iRowOneBased, 1] = null;
// Update the edge weight for the row with the edge's first
// instance.
Debug.Assert(aoEdgeWeightValues[iFirstInstanceRowOneBased, 1]
is Double);
aoEdgeWeightValues[iFirstInstanceRowOneBased, 1] =
(Double)aoEdgeWeightValues[iFirstInstanceRowOneBased, 1]
+ dInitialEdgeWeight;
}
else
{
// No. Add a dictionary entry.
oUniqueEdges.Add(sVertexNamePair, iRowOneBased);
}
}
// Save the updated edge weights to the table.
oEdgeWeightData.set_Value(Missing.Value, aoEdgeWeightValues);
// Delete the duplicate rows.
DeleteDuplicateRows(oEdgeTable, oEdgeWeightColumn, oEdgeWeightData,
aoEdgeWeightValues);
}
示例2: WriteRangeValue
/// <summary>
/// This method writes a given value onto a given range on a excel sheet.
/// </summary>
/// <param name="range">Range instance.</param>
/// <param name="value">Value to be written to that range.</param>
private static void WriteRangeValue(Range range, string value)
{
range.set_Value(XlRangeValueDataType.xlRangeValueDefault, value);
}
示例3: AssertValid
MarkRowsForDeletion
(
ListObject oEdgeTable,
Object [,] aoVertex1NameValues,
Object [,] aoVertex2NameValues,
Object [,] aoThirdColumnValues,
Boolean bGraphIsDirected,
out ListColumn oDeleteIfEmptyColumn,
out Range oDeleteIfEmptyData,
out Object [,] aoDeleteIfEmptyValues
)
{
Debug.Assert(oEdgeTable != null);
Debug.Assert(aoVertex1NameValues != null);
Debug.Assert(aoVertex2NameValues != null);
AssertValid();
HashSet<String> oUniqueEdgeKeys = new HashSet<String>();
if ( !ExcelTableUtil.TryGetOrAddTableColumn(oEdgeTable,
DeleteIfEmptyColumnName, ExcelTableUtil.AutoColumnWidth, null,
out oDeleteIfEmptyColumn, out oDeleteIfEmptyData,
out aoDeleteIfEmptyValues) )
{
throw new InvalidOperationException(
"Can't add marked for deletion column.");
}
Int32 iRows = GetRowCount(aoVertex1NameValues);
for (Int32 iRowOneBased = 1; iRowOneBased <= iRows; iRowOneBased++)
{
String sEdgeKey;
Object oDeleteIfEmpty = 1;
if (
TryGetEdgeKey(iRowOneBased, aoVertex1NameValues,
aoVertex2NameValues, aoThirdColumnValues, bGraphIsDirected,
out sEdgeKey)
&&
!oUniqueEdgeKeys.Add(sEdgeKey)
)
{
// This is a duplicate that is not the first instance. It
// should be deleted.
oDeleteIfEmpty = null;
}
aoDeleteIfEmptyValues[iRowOneBased, 1] = oDeleteIfEmpty;
}
oDeleteIfEmptyData.set_Value(Missing.Value, aoDeleteIfEmptyValues);
}