Repository navigation
Add opt-in XLSX hyperlink support - #168
Kian-kianmehr wants to merge 34 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
|
I love this feature, @Kian-kianmehr - but it seems to have torn out a lot of comments and docstrings. |
|
Thanks for pointing that out! I've restored the missing comments and docstrings and pushed the fix. The issue should now be resolved. |
|
@Kian-kianmehr Thanks for the update, and roping in my fellow maintainer @browniebroke. In thinking about this further, I'm wondering if we want to consider two changes for a major release:
I'm thinking the answer is yes, but wanted to make sure to ask you both for your opinions. |
|
@FlipperPA Thanks for bringing this up! I agree with both ideas. Since the StreamingMixin is significantly more memory-efficient while producing the same output, I think it makes sense to replace the standard Mixin with it altogether. |
|
@Kian-kianmehr I think it makes sense. Let's do it - then I'll merge in the other PRs and we can press a new major release. |
Good questions. For streaming, I haven't followed the PR as I was on holiday at the time, but I guess it makes sense in most cases with the type of response we're returning. My only concern would be the (potential) extra complexity in the implementation for our users? I worked with streaming responses for CSVs and the methods need to fiddle with lazy return values like generators which are a bit less beginner-friendly. The testing side especially had a few footguns, where I need to tell Django to evaluate the response. I don't remember the details but from the top of my head, it sometimes didn't fully consume an iterator which kept some references to model instances which then caused some teardown issues... I haven't had time to look in detail at the StreamingMixin PR but it looks a bit big, which I assume is partially because it needs to duplicate some logic with the non-streaming version, so I can see how having a single version would be easier for us to maintain. For hyperlinks support, I think the answer is bit more clear cut, I don't see a reason why not. I'm happy for the "hyperlink everywhere" change to happen here, but the streaming one feels a bit separate... Just my 2 cents 😄 |
|
@browniebroke Thanks for the detailed feedback! I think we can address these concerns without maintaining two separate implementations. We can keep the existing Mixin interface so users won't have to deal directly with generators or make significant changes to how they use the library. The streaming behavior can remain an implementation detail. For testing, we can add shared helpers to fully consume streaming responses and cover iterator cleanup and resource handling explicitly. That should help avoid the teardown issues you mentioned. On the implementation side, I think we can centralize the workbook generation and field-processing logic, with the only difference being how the response is delivered. This would avoid duplicating the core logic while keeping the API straightforward. |
|
@FlipperPA |
|
@Kian-kianmehr This looks great, thank you. I'll review this and the other PRs in the queue today. I think we're close. |
|
@Kian-kianmehr Oh, one last thought that we can tack on to this PR; do you want to add a section to the README showing how to use the streaming mixin option? We could remove the |
|
@FlipperPA Thanks! Just to clarify, do you think I should make streaming the default approach for version 2.0 and replace the old |
|
Hi @FlipperPA I've completed the final implementation and updated the PR. The XLSX export implementation has been fully replaced with a streaming-based approach, which is now the default behavior for XLSX responses. This removes the need for a separate streaming mixin while preserving the existing API and ensuring that non-XLSX responses, such as JSON, continue to work as expected. I've also updated the tests and documentation to reflect the new implementation and verified the changes against the full test suite. The final version is now pushed to this PR. Thanks for your patience and for reviewing my contribution! |
Summary
XLSXHyperlinkMixinto provide hyperlinks per row and column.Closes #112
Tests
python -m pytest: 175 passed, 2 skipped.