Write component quantities to a table.

def write_how_much(self, file):
        """ Write component quantities to a table.
        """
        report = CaseReport(self.case)

        col1_header = "Attribute"
        col1_width  = 24
        col2_header = "P (MW)"
        col3_header = "Q (MVAr)"
        col_width   = 8

        sep = "="*col1_width +" "+ "="*col_width +" "+ "="*col_width + "\n"

        # Row headers
        file.write(sep)

        file.write("%s" % col1_header.center(col1_width))
        file.write(" ")
        file.write("%s" % col2_header.center(col_width))
        file.write(" ")
        file.write("%s" % col3_header.center(col_width))
        file.write("\n")

        file.write(sep)

        # Rows
        pgen = getattr(report, "total_pgen_capacity")
        qmin, qmax = getattr(report, "total_qgen_capacity")
        file.write("%s %8.1f %4.1f to %4.1f\n" %
            ("Total Gen Capacity".ljust(col1_width), pgen, qmin, qmax))

        pgen = getattr(report, "online_pgen_capacity")
        qmin, qmax = getattr(report, "online_qgen_capacity")
        file.write("%s %8.1f %4.1f to %4.1f\n" %
            ("On-line Capacity".ljust(col1_width), pgen, qmin, qmax))

        pgen = getattr(report, "actual_pgen")
        qgen = getattr(report, "actual_qgen")
        file.write("%s %8.1f %8.1f\n" %
            ("Generation (actual)".ljust(col1_width), pgen, qgen))

        pd = getattr(report, "p_demand")
        qd = getattr(report, "q_demand")
        file.write("%s %8.1f %8.1f\n" %
            ("Load".ljust(col1_width), pd, qd))

        pd = getattr(report, "fixed_p_demand")
        qd = getattr(report, "fixed_q_demand")
        file.write("%s %8.1f %8.1f\n" %
            ("  Fixed".ljust(col1_width), pd, qd))

        pd, pmin = getattr(report, "vload_p_demand")
        qd = getattr(report, "vload_q_demand")
        file.write("%s %4.1f of %4.1f %8.1f\n" %
            ("  Despatchable".ljust(col1_width), pd, pmin, qd))

        pinj = getattr(report, "shunt_pinj")
        qinj = getattr(report, "shunt_qinj")
        file.write("%s %8.1f %8.1f\n" %
            ("Shunt (inj)".ljust(col1_width), pinj, qinj))

        pl, ql = getattr(report, "losses")
        file.write("%s %8.1f %8.1f\n" %
            ("Losses (I^2 * Z)".ljust(col1_width), pl, ql))

        qinj = getattr(report, "branch_qinj")
        file.write("%s %8s %8.1f\n" %
            ("Branch Charging (inj)".ljust(col1_width), "-", qinj))

        pval = getattr(report, "total_tie_pflow")
        qval = getattr(report, "total_tie_qflow")
        file.write("%s %8.1f %8.1f\n" %
            ("Total Inter-tie Flow".ljust(col1_width), pval, qval))

        file.write(sep)
        file.write("\n")

        del report