Server IP : 127.0.0.2 / Your IP : 13.58.157.160 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/lib/python2.7/dist-packages/xlsxwriter/ |
Upload File : |
############################################################################### # # Core - A class for writing the Excel XLSX Worksheet file. # # Copyright 2013-2015, John McNamara, jmcnamara@cpan.org # # Standard packages. from datetime import datetime # Package imports. from . import xmlwriter class Core(xmlwriter.XMLwriter): """ A class for writing the Excel XLSX Core file. """ ########################################################################### # # Public API. # ########################################################################### def __init__(self): """ Constructor. """ super(Core, self).__init__() self.properties = {} ########################################################################### # # Private API. # ########################################################################### def _assemble_xml_file(self): # Assemble and write the XML file. # Write the XML declaration. self._xml_declaration() self._write_cp_core_properties() self._write_dc_title() self._write_dc_subject() self._write_dc_creator() self._write_cp_keywords() self._write_dc_description() self._write_cp_last_modified_by() self._write_dcterms_created() self._write_dcterms_modified() self._write_cp_category() self._write_cp_content_status() self._xml_end_tag('cp:coreProperties') # Close the file. self._xml_close() def _set_properties(self, properties): # Set the document properties. self.properties = properties def _localtime_to_iso8601_date(self, date): # Convert to a ISO 8601 style "2010-01-01T00:00:00Z" date. if not date: date = datetime.now() return date.strftime("%Y-%m-%dT%H:%M:%SZ") ########################################################################### # # XML methods. # ########################################################################### def _write_cp_core_properties(self): # Write the <cp:coreProperties> element. xmlns_cp = ('http://schemas.openxmlformats.org/package/2006/' + 'metadata/core-properties') xmlns_dc = 'http://purl.org/dc/elements/1.1/' xmlns_dcterms = 'http://purl.org/dc/terms/' xmlns_dcmitype = 'http://purl.org/dc/dcmitype/' xmlns_xsi = 'http://www.w3.org/2001/XMLSchema-instance' attributes = [ ('xmlns:cp', xmlns_cp), ('xmlns:dc', xmlns_dc), ('xmlns:dcterms', xmlns_dcterms), ('xmlns:dcmitype', xmlns_dcmitype), ('xmlns:xsi', xmlns_xsi), ] self._xml_start_tag('cp:coreProperties', attributes) def _write_dc_creator(self): # Write the <dc:creator> element. data = self.properties.get('author', '') self._xml_data_element('dc:creator', data) def _write_cp_last_modified_by(self): # Write the <cp:lastModifiedBy> element. data = self.properties.get('author', '') self._xml_data_element('cp:lastModifiedBy', data) def _write_dcterms_created(self): # Write the <dcterms:created> element. date = self.properties.get('created', datetime.now()) xsi_type = 'dcterms:W3CDTF' date = self._localtime_to_iso8601_date(date) attributes = [('xsi:type', xsi_type,)] self._xml_data_element('dcterms:created', date, attributes) def _write_dcterms_modified(self): # Write the <dcterms:modified> element. date = self.properties.get('created', datetime.now()) xsi_type = 'dcterms:W3CDTF' date = self._localtime_to_iso8601_date(date) attributes = [('xsi:type', xsi_type,)] self._xml_data_element('dcterms:modified', date, attributes) def _write_dc_title(self): # Write the <dc:title> element. if 'title' in self.properties: data = self.properties['title'] else: return self._xml_data_element('dc:title', data) def _write_dc_subject(self): # Write the <dc:subject> element. if 'subject' in self.properties: data = self.properties['subject'] else: return self._xml_data_element('dc:subject', data) def _write_cp_keywords(self): # Write the <cp:keywords> element. if 'keywords' in self.properties: data = self.properties['keywords'] else: return self._xml_data_element('cp:keywords', data) def _write_dc_description(self): # Write the <dc:description> element. if 'comments' in self.properties: data = self.properties['comments'] else: return self._xml_data_element('dc:description', data) def _write_cp_category(self): # Write the <cp:category> element. if 'category' in self.properties: data = self.properties['category'] else: return self._xml_data_element('cp:category', data) def _write_cp_content_status(self): # Write the <cp:contentStatus> element. if 'status' in self.properties: data = self.properties['status'] else: return self._xml_data_element('cp:contentStatus', data)