def write_data(self, archive):
        """Write the various xml files into the zip archive."""
        # cleanup all worksheets
        shared_string_table = self._write_string_table(archive)

        archive.writestr(ARC_CONTENT_TYPES, write_content_types(self.workbook))
        if not self.workbook.vba_archive:
            archive.writestr(ARC_ROOT_RELS, write_root_rels(self.workbook))
        archive.writestr(ARC_WORKBOOK_RELS, write_workbook_rels(self.workbook))
        archive.writestr(ARC_APP, write_properties_app(self.workbook))
        archive.writestr(ARC_CORE, write_properties_core(self.workbook.properties))
        if self.workbook.loaded_theme:
            archive.writestr(ARC_THEME, self.workbook.loaded_theme)
        else:
            archive.writestr(ARC_THEME, write_theme())
        archive.writestr(ARC_STYLE, self.style_writer.write_table())
        archive.writestr(ARC_WORKBOOK, write_workbook(self.workbook))

        if self.workbook.vba_archive:
            vba_archive = self.workbook.vba_archive
            for name in vba_archive.namelist():
                for s in ARC_VBA:
                    if name.startswith(s):
                        archive.writestr(name, vba_archive.read(name))
                        break

        self._write_worksheets(archive, shared_string_table, self.style_writer)
Exemple #2
0
    def write_data(self, archive):
        """Write the various xml files into the zip archive."""
        # cleanup all worksheets

        archive.writestr(ARC_CONTENT_TYPES, write_content_types(self.workbook))
        archive.writestr(ARC_ROOT_RELS, write_root_rels(self.workbook))
        archive.writestr(ARC_WORKBOOK_RELS, write_workbook_rels(self.workbook))
        archive.writestr(ARC_APP, write_properties_app(self.workbook))
        archive.writestr(ARC_CORE,
                         write_properties_core(self.workbook.properties))
        if self.workbook.loaded_theme:
            archive.writestr(ARC_THEME, self.workbook.loaded_theme)
        else:
            archive.writestr(ARC_THEME, write_theme())
        archive.writestr(ARC_STYLE, self.style_writer.write_table())
        archive.writestr(ARC_WORKBOOK, write_workbook(self.workbook))

        if self.workbook.vba_archive:
            vba_archive = self.workbook.vba_archive
            for name in vba_archive.namelist():
                for s in ARC_VBA:
                    if name.startswith(s):
                        archive.writestr(name, vba_archive.read(name))
                        break

        self._write_string_table(archive)
        self._write_worksheets(archive, self.style_writer)
Exemple #3
0
 def test_write_properties_core(self):
     self.prop.creator = 'TEST_USER'
     self.prop.last_modified_by = 'SOMEBODY'
     self.prop.created = datetime(2010, 4, 1, 20, 30, 00)
     self.prop.modified = datetime(2010, 4, 5, 14, 5, 30)
     content = write_properties_core(self.prop)
     assert_equals_file_content(
         os.path.join(DATADIR, 'writer', 'expected', 'core.xml'), content)
Exemple #4
0
 def test_write_properties_core(self):
     self.prop.creator = 'TEST_USER'
     self.prop.last_modified_by = 'SOMEBODY'
     self.prop.created = datetime(2010, 4, 1, 20, 30, 00)
     self.prop.modified = datetime(2010, 4, 5, 14, 5, 30)
     content = write_properties_core(self.prop)
     assert_equals_file_content(
             os.path.join(DATADIR, 'writer', 'expected', 'core.xml'),
             content)
 def test_write_properties_core(self):
     self.prop.creator = "TEST_USER"
     self.prop.last_modified_by = "SOMEBODY"
     self.prop.created = datetime(2010, 4, 1, 20, 30, 00)
     self.prop.modified = datetime(2010, 4, 5, 14, 5, 30)
     content = write_properties_core(self.prop)
     reference_file = os.path.join(DATADIR, "writer", "expected", "core.xml")
     with open(reference_file) as expected:
         diff = compare_xml(content, expected.read())
         assert diff is None
 def test_write_properties_core(self):
     self.prop.creator = 'TEST_USER'
     self.prop.last_modified_by = 'SOMEBODY'
     self.prop.created = datetime(2010, 4, 1, 20, 30, 00)
     self.prop.modified = datetime(2010, 4, 5, 14, 5, 30)
     content = write_properties_core(self.prop)
     reference_file = os.path.join(DATADIR, 'writer', 'expected', 'core.xml')
     with open(reference_file) as expected:
         diff = compare_xml(content, expected.read())
         assert diff is None
def test_write_properties_core(datadir):
    datadir.join("writer").chdir()
    prop = DocumentProperties()
    prop.creator = 'TEST_USER'
    prop.last_modified_by = 'SOMEBODY'
    prop.created = datetime(2010, 4, 1, 20, 30, 00)
    prop.modified = datetime(2010, 4, 5, 14, 5, 30)
    content = write_properties_core(prop)
    with open('core.xml') as expected:
        diff = compare_xml(content, expected.read())
        assert diff is None
Exemple #8
0
def test_write_properties_core(datadir):
    datadir.join("writer").chdir()
    prop = DocumentProperties()
    prop.creator = 'TEST_USER'
    prop.last_modified_by = 'SOMEBODY'
    prop.created = datetime(2010, 4, 1, 20, 30, 00)
    prop.modified = datetime(2010, 4, 5, 14, 5, 30)
    content = write_properties_core(prop)
    with open('core.xml') as expected:
        diff = compare_xml(content, expected.read())
        assert diff is None
Exemple #9
0
    def write_data(self, archive):
        """Write the various xml files into the zip archive."""
        # cleanup all worksheets
        shared_string_table = self._write_string_table(archive)
        
        archive.writestr(ARC_CONTENT_TYPES, write_content_types(self.workbook))
        archive.writestr(ARC_ROOT_RELS, write_root_rels(self.workbook))
        archive.writestr(ARC_WORKBOOK_RELS, write_workbook_rels(self.workbook))
        archive.writestr(ARC_APP, write_properties_app(self.workbook))
        archive.writestr(ARC_CORE,
                write_properties_core(self.workbook.properties))
        archive.writestr(ARC_THEME, write_theme())
        archive.writestr(ARC_STYLE, self.style_writer.write_table())
        archive.writestr(ARC_WORKBOOK, write_workbook(self.workbook))

        self._write_worksheets(archive, shared_string_table, self.style_writer)
Exemple #10
0
    def write_data(self, archive):
        """Write the various xml files into the zip archive."""
        # cleanup all worksheets
        shared_string_table = self._write_string_table(archive)

        archive.writestr(ARC_CONTENT_TYPES, write_content_types(self.workbook))
        archive.writestr(ARC_ROOT_RELS, write_root_rels(self.workbook))
        archive.writestr(ARC_WORKBOOK_RELS, write_workbook_rels(self.workbook))
        archive.writestr(ARC_APP, write_properties_app(self.workbook))
        archive.writestr(ARC_CORE,
                         write_properties_core(self.workbook.properties))
        archive.writestr(ARC_THEME, write_theme())
        archive.writestr(ARC_STYLE, self.style_writer.write_table())
        archive.writestr(ARC_WORKBOOK, write_workbook(self.workbook))

        self._write_worksheets(archive, shared_string_table, self.style_writer)