Harness proD API Help
EPLAN.Harness.API.Projects.Documents Namespace / Report Class / Data Property
Example
In This Topic
    Data Property
    In This Topic
    Allows you to access the report table. The document must be open.
    Syntax
    public ReportData Data {get;}
    Exceptions
    ExceptionDescription
    The object is in invalid state. Obtain a new one.

    Internal error of HpD or HpD API.

    IMPORTANT: Throwing this exception changes HpD Api's state to Failed.

    This file is not opened.
    Example
    // Open the report.
    report.Open(false, false);
    
    // Get report data. This action is slow as the object with all the data is constructed each time the property is accessed.
    // Note that we get ReportData object once and then use it for all the queries.
    ReportData reportTable = report.Data;
    
    // You can simply get the report dimensions. Please note that unused columns are also included.
    Console.WriteLine($"The report has {reportTable.ColumnCount} columns and {reportTable.RowCount} rows.");
    
    // Print all the used columns names.
    Console.WriteLine("Report has the following used columns: ");
    foreach (ColumnDescription column in reportTable.Columns)
    {
    	// Print only used columns.
    	if (column.Used)
    		Console.Write($"{column.Name}; ");
    }
    Console.WriteLine();
    
    // Pick a column with a name "Length".
    ColumnDescription lengthColumn = reportTable.Columns.Where(n => n.Name == "Length").FirstOrDefault();
    
    // Print the whole column:
    Console.WriteLine("Length column:");
    for (int i = 0; i < reportTable.RowCount; i++)
    {
    	// You can use ColumnDescription for indexing.
    	Property value = reportTable[i, lengthColumn];
    	
    	// Empty fields are set to null.
    	if (value != null)
    		Console.Write($"{value.ToString()}; ");
    	else
    		Console.Write("<empty>; ");
    }
    Console.WriteLine();
    
    // Print the first row:
    Console.WriteLine("First row:");
    for (int i = 0; i < reportTable.ColumnCount; i++)
    {
    	// You can use coordinates for indexing. Note that unused columns are also present in the table.
    	Property value = reportTable[0, i];
    	
    	// Empty fields are set to null.
    	if (value != null)
    		Console.Write($"{value.ToString()}; ");
    	else
    		Console.Write("<empty>; ");
    }
    Console.WriteLine();
    
    // WRONG! Constructing whole table when accessing each field in a row.
    //for (int i = 0; i < reportTable.ColumnCount; i++)
    //{
    //    // You can use coordinates for indexing.
    //    Property value = report.Data[0, i]; // <<< SLOW! Getter of the Data property constructs the whole table each time!
    //    // Empty fields are set to null.
    //    if (value != null)
    //        _context.ConsoleOutput(value.ToString());
    //}
    
    // Close the report.
    report.Close();
    See Also