public RowBuilder ToRowBuilder([CanBeNull] HouseRo house, XlsResultOutputMode mode)
        {
            var rb = RowBuilder.Start("Hausanschluss Name", HausAnschlussName);

            rb.Add("ObjektID", ObjektID);
            rb.Add("Trafokreis", Trafokreis);
            rb.Add("Hausanschluss Energy During the Night", HausanschlussEnergyDuringNight);
            rb.Add("Hausanschluss Energy During the Day", HausanschlussEnergyDuringDay);
            rb.Add("ISNs", Isns);
            rb.Add("House Assignment Method", AssignmentMethod);
            rb.Add("Assignment Distance", AssignmentDistance);
            rb.Add("Longitude", Lon);
            rb.Add("Latitude", Lat);
            rb.Add("Hausanschluss Status", HaStatus);
            rb.Add("Maximum Anschluss Power", MaximumPower);
            rb.Add("HAStandort", HaStandort);

            if (mode == XlsResultOutputMode.FullLine && house != null)
            {
                rb.Merge(house.ToRowBuilder());
            }

            return(rb);
        }
        public RowBuilder ToRowBuilder([NotNull] HouseRo house, [NotNull] HausAnschlussRo hausAnschluss, XlsResultOutputMode mode)
        {
            var rb = RowBuilder.GetAllProperties(this);

            if (mode == XlsResultOutputMode.FullLine)
            {
                rb.Merge(hausAnschluss.ToRowBuilder(house, mode));
            }
            return(rb);
        }
        public void DumpToExcel([NotNull] string dstPath, XlsResultOutputMode mode)
        {
            RowCollection rc = new RowCollection("GeneratedLoadProfiles", "GeneratedLoadProfiles");

            if (mode == XlsResultOutputMode.ByTrafoStationTree)
            {
                var trafostationen = Houses.SelectMany(x => x.HausAnschlussList).Select(y => y.Trafokreis).Distinct().ToList();
                foreach (var trafostation in trafostationen)
                {
                    rc.Add(RowBuilder.Start("Trafostation", trafostation));
                    foreach (var houseRo in Houses)
                    {
                        if (houseRo.HausAnschlussList.Any(x => x.Trafokreis == trafostation))
                        {
                            rc.Add(houseRo.ToRowBuilder());
                            foreach (HausAnschlussRo hausAnschlussRo in houseRo.HausAnschlussList)
                            {
                                if (hausAnschlussRo.Trafokreis == trafostation)
                                {
                                    rc.Add(hausAnschlussRo.ToRowBuilder(houseRo, mode));
                                    foreach (HouseComponentRo component in hausAnschlussRo.HouseComponents)
                                    {
                                        rc.Add(component.ToRowBuilder(houseRo, hausAnschlussRo, mode));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (mode == XlsResultOutputMode.ByTrafoStationHausanschlussTree)
            {
                var trafostationen = Houses.SelectMany(x => x.HausAnschlussList).Select(y => y.Trafokreis).Distinct().ToList();
                var haros          = Houses.SelectMany(x => x.HausAnschlussList).Distinct().ToList();
                haros.Sort((x, y) => String.Compare(x.ObjektID, y.ObjektID, StringComparison.Ordinal));
                foreach (var trafostation in trafostationen)
                {
                    rc.Add(RowBuilder.Start("Trafostation", trafostation));
                    var filteredHaros = haros.Where(x => x.Trafokreis == trafostation);
                    foreach (var anschlussRo in filteredHaros)
                    {
                        rc.Add(anschlussRo.ToRowBuilder(null, XlsResultOutputMode.ByTrafoStationHausanschlussTree));
                        var housesForAnschluss = Houses.Where(x => x.HausAnschlussList.Contains(anschlussRo)).ToList();
                        foreach (var houseRo in housesForAnschluss)
                        {
                            rc.Add(houseRo.ToRowBuilder());
                            foreach (HouseComponentRo component in anschlussRo.HouseComponents)
                            {
                                rc.Add(component.ToRowBuilder(houseRo, anschlussRo, mode));
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (HouseRo house in Houses)
                {
                    if (mode == XlsResultOutputMode.Tree)
                    {
                        rc.Add(house.ToRowBuilder());
                    }

                    foreach (var anschlussRo in house.HausAnschlussList)
                    {
                        if (mode == XlsResultOutputMode.Tree)
                        {
                            rc.Add(anschlussRo.ToRowBuilder(house, mode));
                        }

                        foreach (var component in anschlussRo.HouseComponents)
                        {
                            rc.Add(component.ToRowBuilder(house, anschlussRo, mode));
                        }
                    }
                }
            }

            XlsxDumper.WriteToXlsx(dstPath, rc);
        }