Skip to content

Add data validation methods and StreamWriter performance improvements#43

Merged
xuri merged 4 commits intoxuri:mainfrom
shady-910:41-improve-streamwriter-performance-add-data-validation-methods
Mar 9, 2026
Merged

Add data validation methods and StreamWriter performance improvements#43
xuri merged 4 commits intoxuri:mainfrom
shady-910:41-improve-streamwriter-performance-add-data-validation-methods

Conversation

@shady-910
Copy link
Copy Markdown
Contributor

Add data validation functionality to excelize-py along with significant StreamWriter performance improvements and new features.

New Data Validation Support

  • DataValidation class with helper methods for setting validation types
  • DataValidationType enum (whole, decimal, list, date, time, textLength, custom)
  • DataValidationOperator enum (between, equal, greaterThan, lessThan, etc.)
  • DataValidationErrorStyle enum (stop, warning, information)
  • add_data_validation() - apply validation rules to cell ranges
  • get_data_validations() - retrieve all validations from a worksheet

StreamWriter Performance Optimizations

  • set_rows() batch method - Write multiple rows in a single FFI call
  • Direct ctypes assignment - Eliminated dataclass reflection overhead
  • start_col parameter - Flexible column positioning for set_rows()
  • set_col_style() method - Efficient bulk column styling during streaming

Cell Class for Styled Streaming

  • New Cell dataclass with value, style_id, and formula fields
  • Enables writing styled cells and formulas through StreamWriter
  • Preserves header formatting when using streaming for large datasets

In-Memory Serialization

  • File.write_to_buffer() - Serialize workbook to bytes without disk I/O

Test plan

  • Test add_data_validation with all validation types
  • Test get_data_validations retrieves existing validations
  • Verify set_rows performance with large datasets (300K+ rows)
  • Test Cell class preserves styles in StreamWriter
  • Verify write_to_buffer matches save_as performance

@xuri xuri added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Feb 25, 2026
@xuri xuri requested a review from Copilot March 5, 2026 08:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the excelize-py FFI surface to support Excel data validations and adds several StreamWriter features aimed at reducing Python↔Go call overhead (batch row writes, bulk column styling), plus a new in-memory serialization API.

Changes:

  • Added DataValidation types/helpers and new add_data_validation() / get_data_validations() bindings.
  • Added StreamWriter enhancements: set_rows() batch write, set_col_style() / set_col_styles() column styling, and Cell support for styled/formula streaming.
  • Added File.write_to_buffer() for in-memory workbook serialization and bumped version to 0.0.9.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
types_py.py Adds DataValidation enums/helpers and a Cell dataclass for styled streaming.
types_go.py Extends ctypes structs for Interface (StyleID/Formula) and adds result structs for new APIs.
types_c.h Extends C ABI structs for Interface, DataValidation, and bytes-return result.
main.go Implements new exported FFI functions (data validation, streaming batch/style, write-to-buffer) and updated interface conversion.
excelize.py Adds Python-facing APIs for new FFI functions plus performance-focused conversions for streaming.
test_excelize.py Adds tests for new StreamWriter/data validation features and adjusts VBA project test path.
setup.py Bumps package version to 0.0.9.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread excelize.py Outdated
Comment thread excelize.py Outdated
Comment thread main.go Outdated
Comment thread main.go Outdated
Comment thread main.go Outdated
Comment thread main.go Outdated
Comment thread test_excelize.py Outdated
Comment thread excelize.py Outdated
Comment thread excelize.py Outdated
xuri added 2 commits March 5, 2026 17:16
…iter-performance-add-data-validation-methods
- Revert changes for functions: py_value_to_c_interface and get_data_validations
- Add example documentation for add_data_validation
- Simplify code
- Update unit tests
- Upgrade GitHub Action packages version
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (645d2ef) to head (906568f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##              main       #43    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files            4         4            
  Lines         3713      3907   +194     
==========================================
+ Hits          3713      3907   +194     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xuri xuri added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 5, 2026
Copy link
Copy Markdown
Owner

@xuri xuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. I made some changes based on your branch.

@xuri xuri merged commit dcb7cdf into xuri:main Mar 9, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants