From 2b70b6272e5759c8a06ee959606303fac8eceea3 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Thu, 5 Nov 2026 09:07:53 +0100 Subject: [PATCH] Match XLSX headers to the official Ontime template --- crates/rundown-converter/src/export.rs | 42 ++++++++++---------- crates/rundown-converter/tests/conversion.rs | 17 ++++++-- docs/rundown-converter.md | 6 ++- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/crates/rundown-converter/src/export.rs b/crates/rundown-converter/src/export.rs index 79d6d99..e0dc5e3 100644 --- a/crates/rundown-converter/src/export.rs +++ b/crates/rundown-converter/src/export.rs @@ -14,6 +14,17 @@ use std::{ }; use zip::{ZipWriter, write::SimpleFileOptions}; +// Match the official Ontime v4 spreadsheet template (not the JSON property names). +const SPREADSHEET_HEADERS: [&str; 7] = [ + "Time Start", + "Time End", + "Duration", + "Cue", + "Title", + "Note", + "Timer Type", +]; + fn entry_values(entry: &Entry, rundown: &Rundown, usage: &str, column: Option<&str>) -> String { entry .source_rows @@ -51,18 +62,10 @@ fn metadata_columns(rundown: &Rundown) -> Vec<(String, String)> { }) .collect::>(); columns.sort_by_key(|(column, _)| column_index(column).unwrap_or(usize::MAX)); - let mut used = [ - "start", - "end", - "duration", - "cue", - "title", - "note", - "timer type", - ] - .into_iter() - .map(str::to_string) - .collect::>(); + let mut used = SPREADSHEET_HEADERS + .iter() + .map(|header| header.to_lowercase()) + .collect::>(); for (column, label) in &mut columns { let base = if label.trim().is_empty() { format!("Metadata {column}") @@ -104,15 +107,12 @@ fn xml_text(value: &str) -> String { fn worksheet(rundown: &Rundown) -> String { let metadata = metadata_columns(rundown); - let mut rows = vec![vec![ - "Start".into(), - "End".into(), - "Duration".into(), - "Cue".into(), - "Title".into(), - "Note".into(), - "Timer type".into(), - ]]; + let mut rows = vec![ + SPREADSHEET_HEADERS + .iter() + .map(|header| (*header).to_string()) + .collect::>(), + ]; rows[0].extend(metadata.iter().map(|(_, label)| label.clone())); for entry in rundown.entries.iter().filter(|entry| entry.kind == "event") { let mut row = vec![ diff --git a/crates/rundown-converter/tests/conversion.rs b/crates/rundown-converter/tests/conversion.rs index f36f223..8610da4 100644 --- a/crates/rundown-converter/tests/conversion.rs +++ b/crates/rundown-converter/tests/conversion.rs @@ -686,13 +686,13 @@ fn xlsx_export_has_ontime_columns_notes_metadata_and_clock_strings() { .map(|cell| cell.text.as_str()) .collect::>(), [ - "Start", - "End", + "Time Start", + "Time End", "Duration", "Cue", "Title", "Note", - "Timer type", + "Timer Type", "Video", ] ); @@ -703,6 +703,17 @@ fn xlsx_export_has_ontime_columns_notes_metadata_and_clock_strings() { assert_eq!(tables[0].rows[1][6].text, "count-down"); assert_eq!(tables[0].rows[1][7].text, "Slides"); assert_eq!(tables[0].rows[2][0].text, "09:10:00"); + + // Metadata must not shadow Ontime's standard timing fields. + let mut rundown = analysis.rundown.unwrap(); + rundown + .mapping + .column_labels + .insert("E".into(), "Time Start".into()); + std::fs::write(&path, export::xlsx(&rundown).unwrap()).unwrap(); + let tables = reader::read(&path).unwrap(); + assert_eq!(tables[0].rows[0][0].text, "Time Start"); + assert_eq!(tables[0].rows[0][7].text, "Time Start (E)"); } #[test] fn invalid_or_cancelled_analysis_never_exports() { diff --git a/docs/rundown-converter.md b/docs/rundown-converter.md index 6351a6c..664dc87 100644 --- a/docs/rundown-converter.md +++ b/docs/rundown-converter.md @@ -272,8 +272,10 @@ operator will start an event on time. Native Ontime JSON is the primary target: it lets the exporter control time relationships and project structure without a second column-mapping step. -XLSX export writes one `Ontime` worksheet with `Start`, `End`, `Duration`, `Cue`, -`Title`, `Note` and `Timer type` columns, followed by selected metadata columns. +XLSX export writes one `Ontime` worksheet with `Time Start`, `Time End`, `Duration`, `Cue`, +`Title`, `Note` and `Timer Type` columns, followed by selected metadata columns. +These headers match the [official Ontime v4 template](https://docs.google.com/spreadsheets/d/1zT6yRgQUaICEiAFR85VEL-E9hAUDujKg6DaWR0iDYmY/edit). +Native JSON uses Ontime's schema keys such as `timeStart`, `timeEnd` and `timerType`. Times use `HH:MM:SS` strings accepted by Ontime. Import the file with Ontime's [spreadsheet importer](https://docs.getontime.no/features/import-spreadsheet/) and map the displayed columns. Schedule gaps remain visible through absolute