Skip to content

Add legacy xls question bank import support#30

Merged
ModerRAS merged 1 commit into
masterfrom
codex/question-bank-xls-support
May 29, 2026
Merged

Add legacy xls question bank import support#30
ModerRAS merged 1 commit into
masterfrom
codex/question-bank-xls-support

Conversation

@ModerRAS

@ModerRAS ModerRAS commented May 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • add ExcelDataReader-based .xls readers for question bank import and auto-detection
  • route KSB/MTB/WLDX/WLDX4/EXC/Simple Excel source reads through the legacy .xls path
  • add NPOI-generated .xls fixtures for format detection/read coverage and update docs

Validation

  • dotnet test ModerBox.QuestionBank.Test\ModerBox.QuestionBank.Test.csproj
  • dotnet test ModerBox.Cli.Test\ModerBox.Cli.Test.csproj
  • dotnet build ModerBox.MCP\ModerBox.MCP.csproj
  • dotnet build ModerBox\ModerBox.csproj (passes with existing warnings)
  • real .xls merge from provided directory: 18 files, 1079 read, 148 deduped, 931 output

Summary by CodeRabbit

  • New Features

    • Added support for legacy Excel files (.xls format) in question bank import and merge operations, complementing existing modern Excel (.xlsx) support.
  • Documentation

    • Updated documentation across multiple README files to reflect that question bank sources now accept both .xlsx and .xls file formats.
  • Tests

    • Added unit tests for legacy Excel format detection and parsing across multiple question bank source formats.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR adds legacy .xls Excel file support to the question bank library. A new workbook reader using ExcelDataReader detects and parses legacy files in Ksb, Mtb, Wldx, Wldx4, Exc, and Simple formats, integrated into existing reader entry points via early legacy detection checks.

Changes

Legacy Excel Support for Question Bank Formats

Layer / File(s) Summary
Legacy Excel workbook infrastructure
ModerBox.QuestionBank/Formats/Excel/LegacyExcelWorkbookReader.cs, ModerBox.QuestionBank/ModerBox.QuestionBank.csproj
LegacyExcelWorkbookReader detects .xls files by extension and reads all worksheets into string matrices via ExcelDataReader; LegacyExcelWorksheet provides cell access, bounds checking, and last-row tracking using 1-based row/column indexing.
Format-specific legacy readers and detection
ModerBox.QuestionBank/Formats/Excel/LegacyExcelReader.cs, ModerBox.QuestionBank/Formats/Excel/SimpleExcelReader.cs
Six format-specific readers (ReadKsbFormat, ReadMtbFormat, ReadWldxFormat, ReadWldx4Format, ReadExcFormat, ReadSimpleFormat) parse rows into Question objects with format-specific column mapping and optional fields; DetectFormat uses header checks and row-level heuristics to distinguish Wldx, Wldx4, and Exc; SimpleExcelReader helpers exposed as internal static for reuse.
Existing reader integration with legacy detection
ModerBox.QuestionBank/Formats/Excel/ExcelReader.cs, ModerBox.QuestionBank/Formats/Ksb/KsbReader.cs, ModerBox.QuestionBank/Formats/Mtb/MtbReader.cs, ModerBox.QuestionBank/Services/QuestionBankConversionService.cs
Each reader entry point (ReadWLDXFormat, ReadWLDX4Format, ReadSimpleFormat, ReadEXCFormat, ReadFromFile in Ksb/Mtb, and DetectExcelFormat) checks legacy status first and delegates to legacy readers, bypassing modern ClosedXML logic when applicable.
Test support and legacy format test cases
ModerBox.QuestionBank.Test/ModerBox.QuestionBank.Test.csproj, ModerBox.QuestionBank.Test/QuestionBankServiceTests.cs
Test project adds NPOI dependencies and license acceptance; test cases verify DetectSourceFormat recognizes legacy Wldx4, Ksb, and Mtb formats and that Read with AutoDetect parses expected question counts and content from generated .xls files.
Documentation updates
ModerBox.Cli/README.md, ModerBox.QuestionBank/README.md, ModerBox.QuestionBank/使用指南.md, README.md
CLI and library README files clarify that multiple Excel formats support both .xlsx and .xls inputs; "Dependencies" section specifies ClosedXML for .xlsx and ExcelDataReader for legacy .xls; main README merge example adds a .xls sample file.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • ModerRAS/ModerBox#29: Overlapping Excel parsing and format detection changes in QuestionBankConversionService and reader integration paths for Ksb/Mtb formats.

Poem

A legacy workbook hops by the light, 🐰
.xls files now read oh-so-right,
Through format detection and parsing with grace,
Old Excel files find their rightful place!
NPOI unlocks what ClosedXML can't take,
A fine merge indeed for question banks' sake. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add legacy xls question bank import support' directly and clearly describes the main change: implementing support for importing legacy .xls question bank files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/question-bank-xls-support

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ModerRAS ModerRAS merged commit 35a9860 into master May 29, 2026
1 of 2 checks passed
@ModerRAS ModerRAS deleted the codex/question-bank-xls-support branch May 29, 2026 08:44
@github-actions

Copy link
Copy Markdown

Code Coverage Report

  • Minimum Required Coverage: 50%
  • Current Coverage: 62.91%

📄 View Full Report

🚀 Keep up the good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant