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 (ExcelTableUtil.TryGetTable(oWorkbook, WorksheetNames.Vertices,
TableNames.Vertices, out oVertexTable))
{
// Make sure the vertex name column exists.
ListColumn oColumn;
if (!ExcelTableUtil.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()
));
}
}