Issue with file sometimes unable to be opened by Numbers
See original GitHub issueHi,
I am using XlsxWriter to do export from Django through an HttpResponse and sometimes the file can’t be opened by Numbers, but can always be opened by LibreOffice.
I am using Python version 2.7.12 and XlsxWriter 1.0.2 and Numbers version 4.3.1 5249 and LibreOffice version 5.3.4.2.
Here is basically how the response is coded, mashed into one script obviously:
from django.http import HttpResponse
from django.views.generic.base import TemplateView
import xlsxwriter
class XlsxResponse(HttpResponse):
def __init__(self, writer_klass, *args, **kwargs):
kwargs["content_type"] = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
super(XlsxResponse, self).__init__(*args, **kwargs)
self._writer_klass = writer_klass
self["Content-Disposition"] = "attachment; filename=\"export.xlsx\""
def process(self, content):
self._writer_klass(self).handle(content)
class XlsxWriter(object):
def __init__(self, response):
self._response = response
self.wb = xlsxwriter.Workbook(response, {"in_memory": True})
# This is implemented by the sub-classes, which handle worksheets
# and formats and stuff.
def _handle(self, content):
raise NotImplementedError
def handle(self, content):
try:
self._handle(content)
finally:
self.wb.close()
class CalendarExportView(TemplateView):
def render_to_response(self, context, **response_kwargs):
response = nexus_http.XlsxResponse(writer_klass=CalendarWriter)
response.process(context)
return response
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
1) 'The document “*.numbers” could not b… - Apple Community
1) 'The document “*.numbers” could not be opened. ' and 2) '"untitled" can't be opened right now. Numbers couldn't read the file'.
Read more >How to recover when Apple Numbers says a file “can't be ...
I named the files created that way with an “09” suffix, and suddenly they opened on the iPad – with all the tables...
Read more >6 Best Ways to Fix Numbers App Not Opening on Mac
6 Best Ways to Fix Numbers App Not Opening on Mac · 1. Force Quit and Relaunch Numbers App · 2. Update the...
Read more >How to Fix "Numbers File Can't Be Opened on macOS 10.14"
The first thing to do is to reboot the device in Safe Mode in order to determine whether there is a newly installed...
Read more >Why Your PC Won't Open NUMBERS Files - File Magic
This error is quite easy to solve. Simply right-click on the NUMBERS file and select Numbers Spreadsheet from the dropdown list to create...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Closing.
Thanks for the update. Hopefully it will help someone else.