本文整理汇总了C#中ListObject类的典型用法代码示例。如果您正苦于以下问题:C# ListObject类的具体用法?C# ListObject怎么用?C# ListObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListObject类属于命名空间,在下文中一共展示了ListObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ExcelTableReader
//*************************************************************************
// Constructor: ExcelTableReader()
//
/// <summary>
/// Initializes a new instance of the <see cref="ExcelTableReader" />
/// class.
/// </summary>
///
/// <param name="table">
/// The table to read. The table must have no hidden columns.
/// </param>
///
/// <remarks>
/// If <paramref name="table" /> has hidden columns, an exception is
/// thrown. Use the <see cref="ExcelColumnHider" /> class to temporarily
/// show all hidden columns if necessary.
/// </remarks>
//*************************************************************************
public ExcelTableReader(
ListObject table
)
{
Debug.Assert(table != null);
m_oTable = table;
m_oColumnIndexesOneBased = new Dictionary<String, Int32>();
ListColumns oColumns = table.ListColumns;
Int32 iColumns = oColumns.Count;
for (Int32 i = 1; i <= iColumns; i++)
{
String sColumnName = oColumns[i].Name;
if ( !String.IsNullOrEmpty(sColumnName) )
{
m_oColumnIndexesOneBased.Add(sColumnName, i);
}
}
m_oCurrentSubrange = null;
m_aoCurrentSubrangeValues = null;
m_iCurrentRowOneBased = Int32.MinValue;
AssertValid();
}
开发者ID:haisreekanth,项目名称:NetMap,代码行数:46,代码来源:ExcelTableReader.cs
示例2: SameListObjectsAreEqual
public void SameListObjectsAreEqual()
{
// Arrange
var values = Many<string>().ToArray();
var listObject1 = new ListObject(values);
var listObject2 = new ListObject(values);
// Assert
listObject1.GetHashCode().Should().Be(listObject2.GetHashCode(), "hash code");
listObject1.Equals(listObject2).Should().BeTrue("Equals");
(listObject1 == listObject2).Should().BeTrue("==");
}
开发者ID:gitter-badger,项目名称:EventFlow,代码行数:12,代码来源:ValueObjectTests.cs
示例3: GetDetails
public override DetailGroup GetDetails(ListObject computer)
{
// You can cast computer to the specific object and get
// more detailed information
if (computer != null)
{
DetailGroup group = new DetailGroup("Computer detailed information");
group.Add("Computer Id:", computer.Id);
return group;
}
else
{
return null;
}
}
开发者ID:dhanzhang,项目名称:Windows-classic-samples,代码行数:17,代码来源:PageAdorner.cs
示例4: ExcelHiddenColumns
ShowHiddenColumns
(
ListObject table
)
{
Debug.Assert(table != null);
ExcelHiddenColumns oExcelHiddenColumns = new ExcelHiddenColumns();
foreach (ListColumn oColumn in table.ListColumns)
{
if ( (Boolean)oColumn.Range.EntireColumn.Hidden )
{
oExcelHiddenColumns.AddLast(oColumn.Name);
ShowOrHideColumn(oColumn, true);
}
}
return (oExcelHiddenColumns);
}
开发者ID:2014-sed-team3,项目名称:term-project,代码行数:20,代码来源:ExcelColumnHider.cs
示例5: AutoFillVertexTable
//*************************************************************************
// Method: AutoFillVertexTable()
//
/// <summary>
/// Runs the application's AutoFill feature on the vertex table.
/// </summary>
///
/// <param name="oVertexTable">
/// The table to autofill.
/// </param>
///
/// <param name="oAutoFillUserSettings">
/// Specifies one or more source-to-destination column mappings.
/// </param>
///
/// <param name="oAutoFillWorkbookResults">
/// Stores the autofill results.
/// </param>
//*************************************************************************
private static void AutoFillVertexTable(
ListObject oVertexTable,
AutoFillUserSettings oAutoFillUserSettings,
AutoFillWorkbookResults oAutoFillWorkbookResults
)
{
Debug.Assert(oVertexTable != null);
Debug.Assert(oAutoFillUserSettings != null);
Debug.Assert(oAutoFillWorkbookResults != null);
Double dSourceCalculationNumber1, dSourceCalculationNumber2;
Int32 iDecimalPlaces;
if ( TryAutoFillColorColumn(oVertexTable,
oAutoFillUserSettings.VertexColorSourceColumnName,
VertexTableColumnNames.Color,
oAutoFillUserSettings.VertexColorDetails,
out dSourceCalculationNumber1,
out dSourceCalculationNumber2,
out iDecimalPlaces
) )
{
oAutoFillWorkbookResults.VertexColorResults =
new AutoFillColorColumnResults(
oAutoFillUserSettings.VertexColorSourceColumnName,
dSourceCalculationNumber1, dSourceCalculationNumber2,
iDecimalPlaces,
oAutoFillUserSettings.VertexColorDetails.DestinationColor1,
oAutoFillUserSettings.VertexColorDetails.DestinationColor2
);
}
AutoFillNumericComparisonColumn(oVertexTable,
oAutoFillUserSettings.VertexShapeSourceColumnName,
VertexTableColumnNames.Shape,
oAutoFillUserSettings.VertexShapeDetails
);
if ( TryAutoFillNumericRangeColumn(oVertexTable,
oAutoFillUserSettings.VertexRadiusSourceColumnName,
VertexTableColumnNames.Radius,
oAutoFillUserSettings.VertexRadiusDetails,
out dSourceCalculationNumber1, out dSourceCalculationNumber2,
out iDecimalPlaces
) )
{
oAutoFillWorkbookResults.VertexRadiusResults =
new AutoFillNumericRangeColumnResults(
oAutoFillUserSettings.VertexRadiusSourceColumnName,
dSourceCalculationNumber1, dSourceCalculationNumber2,
iDecimalPlaces,
oAutoFillUserSettings.VertexRadiusDetails.
DestinationNumber1,
oAutoFillUserSettings.VertexRadiusDetails.
DestinationNumber2
);
}
if ( TryAutoFillNumericRangeColumn(oVertexTable,
oAutoFillUserSettings.VertexAlphaSourceColumnName,
CommonTableColumnNames.Alpha,
oAutoFillUserSettings.VertexAlphaDetails,
out dSourceCalculationNumber1, out dSourceCalculationNumber2,
out iDecimalPlaces
) )
{
oAutoFillWorkbookResults.VertexAlphaResults =
new AutoFillNumericRangeColumnResults(
oAutoFillUserSettings.VertexAlphaSourceColumnName,
dSourceCalculationNumber1, dSourceCalculationNumber2,
iDecimalPlaces,
oAutoFillUserSettings.VertexAlphaDetails.DestinationNumber1,
oAutoFillUserSettings.VertexAlphaDetails.DestinationNumber2
);
}
AutoFillColumnViaCopy(oVertexTable,
oAutoFillUserSettings.VertexLabelSourceColumnName,
VertexTableColumnNames.Label
);
//.........这里部分代码省略.........
开发者ID:haisreekanth,项目名称:NetMap,代码行数:101,代码来源:WorkbookAutoFiller.cs
示例6: AutoFillEdgeTable
//*************************************************************************
// Method: AutoFillEdgeTable()
//
/// <summary>
/// Runs the application's AutoFill feature on the edge table.
/// </summary>
///
/// <param name="oEdgeTable">
/// The table to autofill.
/// </param>
///
/// <param name="oAutoFillUserSettings">
/// Specifies one or more source-to-destination column mappings.
/// </param>
///
/// <param name="oAutoFillWorkbookResults">
/// Stores the autofill results.
/// </param>
//*************************************************************************
private static void AutoFillEdgeTable(
ListObject oEdgeTable,
AutoFillUserSettings oAutoFillUserSettings,
AutoFillWorkbookResults oAutoFillWorkbookResults
)
{
Debug.Assert(oEdgeTable != null);
Debug.Assert(oAutoFillUserSettings != null);
Debug.Assert(oAutoFillWorkbookResults != null);
Double dSourceCalculationNumber1, dSourceCalculationNumber2;
Int32 iDecimalPlaces;
if ( TryAutoFillColorColumn(oEdgeTable,
oAutoFillUserSettings.EdgeColorSourceColumnName,
EdgeTableColumnNames.Color,
oAutoFillUserSettings.EdgeColorDetails,
out dSourceCalculationNumber1, out dSourceCalculationNumber2,
out iDecimalPlaces
) )
{
oAutoFillWorkbookResults.EdgeColorResults =
new AutoFillColorColumnResults(
oAutoFillUserSettings.EdgeColorSourceColumnName,
dSourceCalculationNumber1, dSourceCalculationNumber2,
iDecimalPlaces,
oAutoFillUserSettings.EdgeColorDetails.DestinationColor1,
oAutoFillUserSettings.EdgeColorDetails.DestinationColor2
);
}
if ( TryAutoFillNumericRangeColumn(oEdgeTable,
oAutoFillUserSettings.EdgeWidthSourceColumnName,
EdgeTableColumnNames.Width,
oAutoFillUserSettings.EdgeWidthDetails,
out dSourceCalculationNumber1, out dSourceCalculationNumber2,
out iDecimalPlaces
) )
{
oAutoFillWorkbookResults.EdgeWidthResults =
new AutoFillNumericRangeColumnResults(
oAutoFillUserSettings.EdgeWidthSourceColumnName,
dSourceCalculationNumber1, dSourceCalculationNumber2,
iDecimalPlaces,
oAutoFillUserSettings.EdgeWidthDetails.DestinationNumber1,
oAutoFillUserSettings.EdgeWidthDetails.DestinationNumber2
);
}
if ( TryAutoFillNumericRangeColumn(oEdgeTable,
oAutoFillUserSettings.EdgeAlphaSourceColumnName,
CommonTableColumnNames.Alpha,
oAutoFillUserSettings.EdgeAlphaDetails,
out dSourceCalculationNumber1, out dSourceCalculationNumber2,
out iDecimalPlaces
) )
{
oAutoFillWorkbookResults.EdgeAlphaResults =
new AutoFillNumericRangeColumnResults(
oAutoFillUserSettings.EdgeAlphaSourceColumnName,
dSourceCalculationNumber1, dSourceCalculationNumber2,
iDecimalPlaces,
oAutoFillUserSettings.EdgeAlphaDetails.DestinationNumber1,
oAutoFillUserSettings.EdgeAlphaDetails.DestinationNumber2
);
}
AutoFillNumericComparisonColumn(oEdgeTable,
oAutoFillUserSettings.EdgeVisibilitySourceColumnName,
CommonTableColumnNames.Visibility,
oAutoFillUserSettings.EdgeVisibilityDetails
);
AutoFillColumnViaCopy(oEdgeTable,
oAutoFillUserSettings.EdgeLabelSourceColumnName,
EdgeTableColumnNames.Label
);
}
开发者ID:haisreekanth,项目名称:NetMap,代码行数:97,代码来源:WorkbookAutoFiller.cs
示例7: DifferentListObjectsAreNotEqual
public void DifferentListObjectsAreNotEqual()
{
// Arrange
var listObject1 = new ListObject(Many<string>().ToArray());
var listObject2 = new ListObject(Many<string>().ToArray());
// Assert
listObject1.GetHashCode().Should().NotBe(listObject2.GetHashCode(), "hash code");
listObject1.Equals(listObject2).Should().BeFalse("Equals");
(listObject1 == listObject2).Should().BeFalse("==");
}
开发者ID:joaomajesus,项目名称:EventFlow,代码行数:11,代码来源:ValueObjectTests.cs
示例8: ImportVertices
//*************************************************************************
// Method: ImportVertices()
//
/// <summary>
/// Imports vertices and their attributes from a graph to the vertex
/// worksheet.
/// </summary>
///
/// <param name="oSourceGraph">
/// Graph to import the edges from.
/// </param>
///
/// <param name="asVertexAttributes">
/// Array of vertex attribute names that have been added to the metadata of
/// the graph's vertices. Can be null.
/// </param>
///
/// <param name="oVertexTable">
/// Vertex table the vertices will be imported to.
/// </param>
///
/// <param name="oVertexNameColumnData">
/// Data body range of the vertex name column.
/// </param>
///
/// <param name="oVisibilityColumnData">
/// Data body range of the vertex visibility column.
/// </param>
//*************************************************************************
protected void ImportVertices(
IGraph oSourceGraph,
String [] asVertexAttributes,
ListObject oVertexTable,
Range oVertexNameColumnData,
Range oVisibilityColumnData
)
{
Debug.Assert(oSourceGraph != null);
Debug.Assert(oVertexTable != null);
Debug.Assert(oVertexNameColumnData != null);
Debug.Assert(oVisibilityColumnData != null);
AssertValid();
// Create a dictionary that maps vertex names to row numbers in the
// vertex worksheet.
Dictionary<String, Int32> oVertexDictionary =
new Dictionary<String, Int32>();
Object [,] aoVertexNameValues =
ExcelUtil.GetRangeValues(oVertexNameColumnData);
Int32 iRows = oVertexNameColumnData.Rows.Count;
if (iRows == 1 && aoVertexNameValues[1, 1] == null)
{
// Range.get_Value() (and therefore ExcelUtil.GetRangeValues())
// returns a single null cell when the table is empty. Work around
// this.
iRows = 0;
}
for (Int32 iRowOneBased = 1; iRowOneBased <= iRows; iRowOneBased++)
{
String sVertexName;
if ( ExcelUtil.TryGetNonEmptyStringFromCell(aoVertexNameValues,
iRowOneBased, 1, out sVertexName) )
{
oVertexDictionary[sVertexName] = iRowOneBased;
}
}
aoVertexNameValues = null;
// Create a list of vertices not already included in the vertex table.
// This can occur when the graph has isolated vertices.
List<String> oIsolatedVertexNames = new List<String>();
foreach (IVertex oVertex in oSourceGraph.Vertices)
{
String sVertexName = oVertex.Name;
if ( !oVertexDictionary.ContainsKey(sVertexName) )
{
oIsolatedVertexNames.Add(sVertexName);
}
}
Int32 iIsolatedVertices = oIsolatedVertexNames.Count;
if (iIsolatedVertices > 0)
{
// Append the isolated vertices to the table. The vertex
// visibilities should be set to Show to force them to be shown
// even though they are not included in edges.
String [,] asAddedVertexNameValues =
//.........这里部分代码省略.........
开发者ID:haisreekanth,项目名称:NetMap,代码行数:101,代码来源:GraphImporter.cs
示例9: ImportEdges
//*************************************************************************
// Method: ImportEdges()
//
/// <summary>
/// Imports edges and their attributes from a graph to the edge worksheet.
/// </summary>
///
/// <param name="oSourceGraph">
/// Graph to import the edges from.
/// </param>
///
/// <param name="asEdgeAttributes">
/// Array of edge attribute names that have been added to the metadata of
/// the graph's edges. Can be null.
/// </param>
///
/// <param name="oEdgeTable">
/// Edge table the edges will be imported to.
/// </param>
///
/// <param name="oVertex1NameColumnData">
/// Data body range of the vertex 1 name column.
/// </param>
///
/// <param name="oVertex2NameColumnData">
/// Data body range of the vertex 2 name column.
/// </param>
///
/// <param name="bAppendToTable">
/// true to append the edges to any edges already in the edge table, false
/// to overwrite any edges.
/// </param>
//*************************************************************************
protected void ImportEdges(
IGraph oSourceGraph,
String [] asEdgeAttributes,
ListObject oEdgeTable,
Range oVertex1NameColumnData,
Range oVertex2NameColumnData,
Boolean bAppendToTable
)
{
Debug.Assert(oSourceGraph != null);
Debug.Assert(oEdgeTable != null);
Debug.Assert(oVertex1NameColumnData != null);
Debug.Assert(oVertex2NameColumnData != null);
AssertValid();
Int32 iRowOffsetToWriteTo = 0;
if (bAppendToTable)
{
iRowOffsetToWriteTo =
ExcelUtil.GetOffsetOfFirstEmptyTableRow(oEdgeTable);
ExcelUtil.OffsetRange(ref oVertex1NameColumnData,
iRowOffsetToWriteTo, 0);
ExcelUtil.OffsetRange(ref oVertex2NameColumnData,
iRowOffsetToWriteTo, 0);
}
Range [] aoEdgeAttributeColumnData = null;
Object [][,] aaoEdgeAttributeValues = null;
Int32 iEdgeAttributes = 0;
IEdgeCollection oEdges = oSourceGraph.Edges;
Int32 iEdges = oEdges.Count;
// Create vertex name and edge attribute arrays that will be written to
// the edge table.
Object [,] aoVertex1NameValues =
ExcelUtil.GetSingleColumn2DArray(iEdges);
Object [,] aoVertex2NameValues =
ExcelUtil.GetSingleColumn2DArray(iEdges);
if (asEdgeAttributes != null)
{
iEdgeAttributes = asEdgeAttributes.Length;
aoEdgeAttributeColumnData = new Range[iEdgeAttributes];
aaoEdgeAttributeValues = new Object[iEdgeAttributes][,];
ListColumn oEdgeAttributeColumn;
Range oEdgeAttributeColumnData;
for (Int32 i = 0; i < iEdgeAttributes; i++)
{
String sEdgeAttribute = asEdgeAttributes[i];
if (
!ExcelUtil.TryGetOrAddTableColumn(oEdgeTable,
sEdgeAttribute, ExcelUtil.AutoColumnWidth, null,
out oEdgeAttributeColumn)
||
!ExcelUtil.TryGetTableColumnData(oEdgeAttributeColumn,
out oEdgeAttributeColumnData)
)
{
throw new WorkbookFormatException(
"The " + sEdgeAttribute + " column couldn't be added."
//.........这里部分代码省略.........
开发者ID:haisreekanth,项目名称:NetMap,代码行数:101,代码来源:GraphImporter.cs
示例10: GetRequiredTables
//*************************************************************************
// Method: GetRequiredTables()
//
/// <summary>
/// Gets the tables required for populating the vertex worksheet.
/// </summary>
///
/// <param name="oWorkbook">
/// Workbook containing the graph data.
/// </param>
///
/// <param name="oEdgeTable">
/// Where the edge table gets stored.
/// </param>
///
/// <param name="oVertexTable">
/// Where the vertex table gets stored.
/// </param>
///
/// <remarks>
/// This method checks for tables and table columns that are required for
/// vertex worksheet population.
///
/// <para>
/// If there is a problem with the workbook, a <see
/// cref="WorkbookFormatException" /> is thrown.
/// </para>
///
/// </remarks>
//*************************************************************************
protected void GetRequiredTables(
Microsoft.Office.Interop.Excel.Workbook oWorkbook,
out ListObject oEdgeTable,
out ListObject oVertexTable
)
{
Debug.Assert(oWorkbook != null);
AssertValid();
// Get the required table that contains edge data. GetEdgeTable()
// checks for the required vertex name columns.
EdgeWorksheetReader oEdgeWorksheetReader = new EdgeWorksheetReader();
oEdgeTable = oEdgeWorksheetReader.GetEdgeTable(oWorkbook);
// Normally, the vertex table isn't required, but to avoid having to
// create the table in code if it's missing, require it here.
if ( ExcelUtil.TryGetTable(oWorkbook, WorksheetNames.Vertices,
TableNames.Vertices, out oVertexTable) )
{
// Make sure the vertex name column exists.
ListColumn oColumn;
if ( !ExcelUtil.TryGetTableColumn(oVertexTable,
VertexTableColumnNames.VertexName, out oColumn) )
{
oVertexTable = null;
}
}
else
{
oVertexTable = null;
}
if (oVertexTable == null)
{
throw new WorkbookFormatException(String.Format(
"To use this feature, there must be a worksheet named \"{0}\""
+ " that contains a table named \"{1}\", and that table must"
+ " contain a column named \"{2}\"."
+ "\r\n\r\n"
+ "{3}"
,
WorksheetNames.Vertices,
TableNames.Vertices,
VertexTableColumnNames.VertexName,
ErrorUtil.GetTemplateMessage()
) );
}
}
开发者ID:haisreekanth,项目名称:NetMap,代码行数:84,代码来源:VertexWorksheetPopulator.cs
示例11: ActivateWorksheet
ActivateWorksheet
(
ListObject table
)
{
Debug.Assert(table != null);
Debug.Assert(table.Parent is Worksheet);
ActivateWorksheet((Worksheet)table.Parent);
}
开发者ID:cpatmoore,项目名称:bio,代码行数:11,代码来源:ExcelUtil.cs
示例12: return
TryGetTableColumnData
(
ListObject table,
String columnName,
out Range tableColumnData
)
{
Debug.Assert(table != null);
Debug.Assert(!String.IsNullOrEmpty(columnName));
tableColumnData = null;
ListColumn oColumn;
return (
TryGetTableColumn(table, columnName, out oColumn)
&&
TryGetTableColumnData(oColumn, out tableColumnData)
);
}
开发者ID:cpatmoore,项目名称:bio,代码行数:20,代码来源:ExcelUtil.cs
示例13: catch
TryAddOrInsertTableColumn
(
ListObject table,
String columnName,
Int32 oneBasedColumnIndex,
Double columnWidthChars,
String columnStyle,
out ListColumn listColumn
)
{
Debug.Assert(table != null);
Debug.Assert(!String.IsNullOrEmpty(columnName));
Debug.Assert(oneBasedColumnIndex == -1 || oneBasedColumnIndex >= 1);
Debug.Assert(columnWidthChars == AutoColumnWidth ||
columnWidthChars >= 0);
listColumn = null;
Object oPosition;
ListColumns oColumns = table.ListColumns;
Int32 iColumns = oColumns.Count;
Double[] adColumnWidthChars = null;
if (oneBasedColumnIndex == -1)
{
oPosition = Missing.Value;
}
else
{
oPosition = oneBasedColumnIndex;
// When inserting a column, Excel messes up the widths of the
// columns after the insertion point. Save the widths of those
// columns.
if (oneBasedColumnIndex <= iColumns)
{
adColumnWidthChars =
new Double[iColumns - oneBasedColumnIndex + 1];
for (Int32 iOneBasedIndex = oneBasedColumnIndex;
iOneBasedIndex <= iColumns; iOneBasedIndex++)
{
adColumnWidthChars[iOneBasedIndex - oneBasedColumnIndex] =
(Double)oColumns[iOneBasedIndex].Range.ColumnWidth;
}
}
}
try
{
listColumn = oColumns.Add(oPosition);
}
catch (COMException oCOMException)
{
if (oCOMException.ErrorCode == -2146827284)
{
// This can happen, for example, if adding a table column
// would cause a merged cells to unmerge, the user is asked
// if he wants to allow the unmerge, and he says no.
return (false);
}
throw;
}
// Set various properties on the new column.
listColumn.Name = columnName;
Range oColumnRange = listColumn.Range;
if (columnWidthChars == AutoColumnWidth)
{
oColumnRange.EntireColumn.AutoFit();
}
else
{
oColumnRange.ColumnWidth = columnWidthChars;
}
oColumnRange.Validation.Delete();
SetRangeStyle(oColumnRange, columnStyle);
if (adColumnWidthChars != null)
{
// Restore the widths of the columns after the insertion point.
for (Int32 iOneBasedIndex = oneBasedColumnIndex;
iOneBasedIndex <= iColumns; iOneBasedIndex++)
{
oColumns[iOneBasedIndex + 1].Range.ColumnWidth =
adColumnWidthChars[iOneBasedIndex - oneBasedColumnIndex];
}
}
return (true);
//.........这里部分代码省略.........
开发者ID:cpatmoore,项目名称:bio,代码行数:101,代码来源:ExcelUtil.cs
示例14: FillVertexTable
//*************************************************************************
// Method: FillVertexTable()
//
/// <summary>
/// Fills in the vertex name column with specified vertex names.
/// </summary>
///
/// <param name="oVertexTable">
/// Vertex table.
/// </param>
///
/// <param name="oVertexNameDictionary">
/// Dictionary of vertex names. The key is the vertex name and the value
/// is unused. IMPORTANT: This method might remove some entries from the
/// dictionary.
/// </param>
///
/// <remarks>
/// IMPORTANT: This method might remove some entries from the dictionary.
/// </remarks>
//*************************************************************************
protected void FillVertexTable(
ListObject oVertexTable,
Dictionary<String, Char> oVertexNameDictionary
)
{
Debug.Assert(oVertexTable != null);
Debug.Assert(oVertexNameDictionary != null);
AssertValid();
// There may already be some vertex names in the table. For each
// existing name, remove the name from the dictionary.
Int32 iExistingRows = 0;
Range oVertexNameRange;
if ( ExcelUtil.TryGetTableColumnData(oVertexTable,
VertexTableColumnNames.VertexName, out oVertexNameRange) )
{
iExistingRows = oVertexNameRange.Rows.Count;
// Read the vertex names all at once.
Object [,] aoVertexNameValues =
ExcelUtil.GetRangeValues(oVertexNameRange);
// Loop through the vertices.
for (Int32 iRowOneBased = 1; iRowOneBased <= iExistingRows;
iRowOneBased++)
{
// Get the vertex name and remove it from the dictionary.
String sVertexName;
if ( ExcelUtil.TryGetNonEmptyStringFromCell(
aoVertexNameValues, iRowOneBased, 1, out sVertexName) )
{
oVertexNameDictionary.Remove(sVertexName);
}
}
}
// Now create an array for the vertices that remain in the dictionary.
// These are vertices that were in the edge table but not the vertex
// table.
Int32 iRowsToAdd = oVertexNameDictionary.Count;
if (iRowsToAdd == 0)
{
return;
}
String [,] asAddedVertexNameValues = new String [iRowsToAdd, 1];
Int32 iIndex = 0;
foreach (KeyValuePair<String, Char> oKeyValuePair in
oVertexNameDictionary)
{
asAddedVertexNameValues[iIndex, 0] = oKeyValuePair.Key;
iIndex++;
}
// The table may be empty or contain empty rows. If so, the remaining
// vertices should be appended after the last non-empty row.
Int32 iLastNonEmptyRowOneBased;
Range oDataBodyRange = oVertexTable.DataBodyRange;
if (
oDataBodyRange == null
||
!ExcelUtil.TryGetLastNonEmptyRow(oDataBodyRange,
out iLastNonEmptyRowOneBased)
)
//.........这里部分代码省略.........
开发者ID:haisreekanth,项目名称:NetMap,代码行数:101,代码来源:VertexWorksheetPopulator.cs
示例15: ReadEdgeTable
//*************************************************************************
// Method: ReadEdgeTable()
//
/// <summary>
/// Reads the edge table and populates a dictionary with unique vertex
/// names.
/// </summary>
///
/// <param name="oEdgeTable">
/// Edge table.
/// </param>
///
/// <param name="oVertexNameDictionary">
/// Dictionary to populate. The key is the vertex name and the value is
/// not used.
/// </param>
//*************************************************************************
protected void ReadEdgeTable(
ListObject oEdgeTable,
Dictionary<String, Char> oVertexNameDictionary
)
{
Debug.Assert(oEdgeTable != null);
Debug.Assert(oVertexNameDictionary != null);
Debug.Assert(oVertexNameDictionary.Count == 0);
AssertValid();
// Get the vertex name column ranges.
Range oVertex1NameRange, oVertex2NameRange;
if ( !ExcelUtil.TryGetTableColumnData(oEdgeTable,
EdgeTableColumnNames.Vertex1Name, out oVertex1NameRange)
||
!ExcelUtil.TryGetTableColumnData(oEdgeTable,
EdgeTableColumnNames.Vertex2Name, out oVertex2NameRange)
)
{
return;
}
Int32 iRows = oVertex1NameRange.Rows.Count;
Debug.Assert(oVertex2NameRange.Rows.Count == iRows);
// Read the vertex names all at once.
Object [,] aoVertex1NameValues =
ExcelUtil.GetRangeValues(oVertex1NameRange);
Object [,] aoVertex2NameValues =
ExcelUtil.GetRangeValues(oVertex2NameRange);
// Loop through the edges.
for (Int32 iRowOneBased = 1; iRowOneBased <= iRows; iRowOneBased++)
{
// Get the vertex names and add them to the dictionary. Use
// Dictionary.Item() instead of Dictionary.Add() to allow for
// duplicate vertex names.
String sVertex1Name, sVertex2Name;
if ( ExcelUtil.TryGetNonEmptyStringFromCell(aoVertex1NameValues,
iRowOneBased, 1, out sVertex1Name) )
{
oVertexNameDictionary[sVertex1Name] = ' ';
}
if ( ExcelUtil.TryGetNonEmptyStringFromCell(aoVertex2NameValues,
iRowOneBased, 1, out sVertex2Name) )
{
oVertexNameDictionary[sVertex2Name] = ' ';
}
}
}
开发者ID:haisreekanth,项目名称:NetMap,代码行数:76,代码来源:VertexWorksheetPopulator.cs
示例16: ImportVertexAttributes
//*************************************************************************
// Method: ImportVertexAttributes()
//
/// <summary>
/// Imports attributes from the graph's vertices to the vertex worksheet.
/// </summary>
///
/// <param name="oSourceGraph">
/// Graph to import the edges from.
/// </param>
///
/// <param name="asVertexAttributes">
/// Array of vertex attribute names that have been added to the metadata of
/// the graph's vertices. Can't be null.
/// </param>
///
/// <param name="oVertexDictionary">
/// The key is a vertex name and the value is the one-based row offset.
/// </param>
///
/// <param name="oVertexTable">
/// Vertex table the vertices will be imported to.
/// </param>
//*************************************************************************
protected void ImportVertexAttributes(
IGraph oSourceGraph,
String [] asVertexAttributes,
Dictionary<String, Int32> oVertexDictionary,
ListObject oVertexTable
)
{
Debug.Assert(oSourceGraph != null);
Debug.Assert(asVertexAttributes != null);
Debug.Assert(oVertexDictionary != null);
Debug.Assert(oVertexTable != null);
AssertValid();
// Create vertex attribute arrays that will be written to the vertex
// table.
Int32 iVertexAttributes = asVertexAttributes.Length;
Range [] aoVertexAttributeColumnData = new Range[iVertexAttributes];
Object [][,] aaoVertexAttributeValues =
new Object[iVertexAttributes][,];
ListColumn oVertexAttributeColumn;
Range oVertexAttributeColumnData;
for (Int32 i = 0; i < iVertexAttributes; i++)
{
String sVertexAttribute = asVertexAttributes[i];
if (
!ExcelUtil.TryGetOrAddTableColumn(oVertexTable,
sVertexAttribute, ExcelUtil.AutoColumnWidth, null,
out oVertexAttributeColumn)
||
!ExcelUtil.TryGetTableColumnData(oVertexAttributeColumn,
out oVertexAttributeColumnData)
)
{
throw new WorkbookFormatException( String.Format(
"The {0} column couldn't be added."
,
sVertexAttribute
) );
}
aoVertexAttributeColumnData[i] = oVertexAttributeColumnData;
aaoVertexAttributeValues[i] =
ExcelUtil.GetRangeValues(oVertexAttributeColumnData);
}
foreach (IVertex oVertex in oSourceGraph.Vertices)
{
String sVertexName = oVertex.Name;
Object oVertexAttribute;
Int32 iOneBasedRowOffset;
if ( !oVertexDictionary.TryGetValue(sVertexName,
out iOneBasedRowOffset) )
{
Debug.Assert(false);
}
for (Int32 i = 0; i < iVertexAttributes; i++)
{
if ( oVertex.TryGetValue(asVertexAttributes[i],
out oVertexAttribute) )
{
Debug.Assert(iOneBasedRowOffset >= 1);
Debug.Assert( iOneBasedRowOffset <=
aaoVertexAttributeValues[i].GetUpperBound(0) );
//.........这里部分代码省略.........
开发者ID:haisreekanth,项目名称:NetMap,代码行数:101,代码来源:GraphImporter.cs
示例17: FormatSheet
private void FormatSheet()
{
_excelApp = Globals.ThisAddIn.Application;
var excelBook = _excelApp.Workbooks.Add();
Worksheet excelSheet = excelBook.ActiveSheet;
_sheetName01 = "MSO261 - Pronto Pago";
excelSheet.Name = _sheetName01;
#region Instructions
_cells.GetCell(1, 1).Value = "CERREJÓN";
_cells.GetCell(1, 1).Style = _cells.GetStyle(StyleConstants.HeaderDefault);
_cells.MergeCells(1, 1, 1, 2);
_cells.GetCell("B1").Value = "Registro y Verificacion de Pronto Pagos";
_cells.GetCell("B1").Style = _cells.GetStyle(StyleConstants.HeaderSize17);
_cells.MergeCells(2, 1, 7, 2);
#endregion
#region Datos
_cells.GetCell(1, 4).Value = "Porcentaje de Descuento";
_cells.GetCell(1, 5).Value = "Dias";
_cells.GetCell(1, 6).Value = "Branch Code";
_cells.GetCell(1, 7).Value = "Bank Account";
_cells.GetRange(1, 4, 1, 7).Style = _cells.GetStyle(StyleConstants.TitleRequired);
_cells.GetCell(1, TittleRow).Value = "Supplier";
_cells.GetCell(2, TittleRow).Value = "Factura";
_cells.GetCell(3, TittleRow).Value = "Fecha pago solicitada";
_cells.GetCell(4, TittleRow).Value = "Fecha pago original";
_cells.GetCell(5, TittleRow).Value = "PMT Status";
_cells.GetCell(6, TittleRow).Value = "Proveedor";
_cells.GetCell(7, TittleRow).Value = "Codigo Banco Original";
_cells.GetCell(8, TittleRow).Value = "ST";
_cells.GetCell(9, TittleRow).Value = "Vr total factura";
_cells.GetCell(10, TittleRow).Value = "Vr Base de Descuento";
_cells.GetCell(11, TittleRow).Value = "Diferencia";
_cells.GetCell(12, TittleRow).Value = "Descuento calculado";
_cells.GetCell(13, TittleRow).Value = "Vr descuento aplicado ";
_cells.GetCell(14, TittleRow).Value = "Fecha de pago modificada";
_cells.GetCell(15, TittleRow).Value = "Banco de Pago Modificado";
_cells.GetCell(ResultColumn, TittleRow).Value = "Result";
_cells.GetRange(1, TittleRow, ResultColumn, TittleRow).Style = _cells.GetStyle(StyleConstants.TitleRequired);
_excelSheetItems = excelSheet.ListObjects.AddEx(XlListObjectSourceType.xlSrcRange, _cells.GetRange(1, TittleRow, ResultColumn, TittleRow + 1), XlListObjectHasHeaders: XlYesNoGuess.xlYes);
_cells.GetRange(1, TittleRow + 1, ResultColumn, _excelSheetItems.ListRows.Count + TittleRow).NumberFormat = "@";
_cells.GetRange(9, TittleRow + 1, 10, _excelSheetItems.ListRows.Count + TittleRow).NumberFormat = "$ #,##0.00";
_cells.GetRange(12, TittleRow + 1, 13, _excelSheetItems.ListRows.Count + TittleRow).NumberFormat = "$ #,##0.00";
_cells.GetCell(2, 4).NumberFormat = "0.00%";
excelSheet.Cells.
|
请发表评论