private IList <ElementItem> GetElements(IExcelFileReader reader, IList <DesignItem> designs) { var result = new List <ElementItem>(); reader.SetActiveSheet("ElementData"); while (reader.ReadRow()) { if (reader.GetColumnCount() < 3) { continue; } int material_id = 0; int design_id = 0; int max_usage = 0; if (!reader.ReadColumnAsInt(0, out material_id)) { continue; } if (!reader.ReadColumnAsInt(1, out design_id)) { continue; } if (!reader.ReadColumnAsInt(2, out max_usage)) { continue; } result.Add(new ElementItem() { MaterialID = material_id, MaxUsage = max_usage, DesignAndOrientations = designs.Where(x => x.DesignID == design_id) }); } return(result); }
private List <DesignItem> GetDesignItems(IExcelFileReader reader) { reader.SetActiveSheet("DesignData"); var designs = new List <DesignItem>(); while (reader.ReadRow()) { if (reader.GetColumnCount() < 7) { continue; } int design_id = 0; string blname = ""; int size_x = 0; int size_z = 0; string transform = ""; decimal offset_x = 0; decimal offset_z = 0; if (!reader.ReadColumnAsInt(0, out design_id)) { continue; } if (!reader.ReadColumnAsText(1, out blname)) { continue; } if (!reader.ReadColumnAsInt(2, out size_x)) { continue; } if (!reader.ReadColumnAsInt(3, out size_z)) { continue; } if (!reader.ReadColumnAsText(4, out transform)) { continue; } if (!reader.ReadColumnAsDecimal(5, out offset_x)) { continue; } if (!reader.ReadColumnAsDecimal(6, out offset_z)) { continue; } designs.Add(new DesignItem() { DesignID = design_id, BricklinkName = blname, SizeX = size_x, SizeZ = size_z, Transform = transform, OffsetX = (float)offset_x, OffsetZ = (float)offset_z, }); if (reader.GetColumnCount() >= 10) { if (!reader.ReadColumnAsText(7, out transform)) { continue; } if (!reader.ReadColumnAsDecimal(8, out offset_x)) { continue; } if (!reader.ReadColumnAsDecimal(9, out offset_z)) { continue; } designs.Add(new DesignItem() { DesignID = design_id, BricklinkName = blname, SizeX = size_z, SizeZ = size_x, // Flipped 90 degree Transform = transform, OffsetX = (float)offset_x, OffsetZ = (float)offset_z, }); } } return(designs); }