# Copy a matrix data into Excel # # # (c) 2005-2006 TSS-Transport Simulation Systems # from win32com.client import Dispatch # Variables used to configure this script # # Identifier of the matrix matrixId = 266 # Copy the matrix def copyMatrix( matrix, excelSheet ): # Get the centroid configuration, config = matrix.getCentroidConfiguration() # List of centroids centroids = config.getCentroidsInOrder() # Read the trips... i = 1 for origin in centroids: j = 1 for destination in centroids: trips = matrix.getTrips( origin, destination ) # and copy them to excel excelSheet.Cells( i,j ).Value = trips j = j + 1 i = i + 1 matrix = model.getCatalog().find( matrixId ) if matrix != None and matrix.isA( "GKODMatrix" ): xlApp = Dispatch("Excel.Application") xlApp.Visible = 1 xlApp.Workbooks.Add() copyMatrix( matrix, xlApp.ActiveWorkbook.ActiveSheet ) print "Done"