Files
KArtSell.Aegis/docs/Design/kbx-foundation-v52-fe-operational-navigation-screen-anatomy/tests/backend/KbxSyntheticImportWorkbook.cs
T
kjh2064 c41e5063b7 chore: remove kbx-foundation-v36 reference (superseded by v4 implementation)
Removed entire kbx-foundation-v36 directory as it's been replaced by
the new KBX Foundation v4 patterns implemented in this session:
- Registry-driven screen definitions
- Density-aware UI adapter components
- Feature module templates (ShadowRun, Models)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-08-12 01:39:58 +09:00

39 lines
1.5 KiB
C#

using System.Text.Json;
using ClosedXML.Excel;
namespace Kbx.Tests.Scenarios;
/// <summary>Builds an XLSX from the checked-in synthetic JSON fixture. No production spreadsheet is stored in source control.</summary>
public static class KbxSyntheticImportWorkbook
{
private sealed record Fixture(string Sheet, string[] Columns, JsonElement[][] Rows);
public static void Build(string jsonPath, string xlsxPath)
{
var fixture = JsonSerializer.Deserialize<Fixture>(File.ReadAllText(jsonPath),
new JsonSerializerOptions { PropertyNameCaseInsensitive = true })
?? throw new InvalidOperationException("Invalid synthetic import fixture.");
using var workbook = new XLWorkbook();
var sheet = workbook.Worksheets.Add(fixture.Sheet);
for (var c = 0; c < fixture.Columns.Length; c++)
sheet.Cell(1, c + 1).Value = fixture.Columns[c];
for (var r = 0; r < fixture.Rows.Length; r++)
for (var c = 0; c < fixture.Rows[r].Length; c++)
{
var cell = sheet.Cell(r + 2, c + 1);
var value = fixture.Rows[r][c];
cell.Value = value.ValueKind switch
{
JsonValueKind.Number when value.TryGetDecimal(out var number) => number,
JsonValueKind.String => value.GetString() ?? string.Empty,
JsonValueKind.True => true,
JsonValueKind.False => false,
_ => value.ToString()
};
}
workbook.SaveAs(xlsxPath);
}
}