Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions xlsxwriter/workbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import re
import os
import operator
import time
import warnings
from warnings import warn
from datetime import datetime
from zipfile import ZipFile, ZIP_DEFLATED
from zipfile import ZipFile, ZipInfo, ZIP_DEFLATED
from struct import unpack

from .compatibility import int_types, num_types, str_types, force_unicode
Expand Down Expand Up @@ -626,13 +627,19 @@ def _store_workbook(self):
# Add XML sub-files to the Zip file with their Excel filename.
for os_filename, xml_filename, is_binary in xml_files:
if self.in_memory:

zipinfo = ZipInfo(xml_filename, (1980, 1, 1, 0, 0, 0))
if is_binary:
xlsx_file.writestr(xml_filename, os_filename.getvalue())
xlsx_file.writestr(zipinfo, os_filename.getvalue())
else:
xlsx_file.writestr(xml_filename,
xlsx_file.writestr(zipinfo,
os_filename.getvalue().encode('utf-8'))
else:
# The files are tempfiles.

timestamp = time.mktime((1980, 1, 1, 0, 0, 0, 0, 0, 0))
os.utime(os_filename, (timestamp, timestamp))

xlsx_file.write(os_filename, xml_filename)
os.remove(os_filename)

Expand Down