Exemplo n.º 1
0
def read_worksheet(xml_source, parent, preset_title, string_table,
                   style_table, workbook_name=None, sheet_codename=None):
    """Read an xml worksheet"""
    if workbook_name and sheet_codename:
        ws = IterableWorksheet(parent, preset_title, workbook_name,
                sheet_codename, xml_source, string_table)
    else:
        ws = Worksheet(parent, preset_title)
        fast_parse(ws, xml_source, string_table, style_table)
    return ws
Exemplo n.º 2
0
    def create_sheet(self, index=None, title=None):
        """Create a worksheet (at an optional index).

        :param index: optional position at which the sheet will be inserted
        :type index: int

        """

        if self.__optimized_read:
            raise ReadOnlyWorkbookException(
                'Cannot create new sheet in a read-only workbook')

        if self.__optimized_write:
            new_ws = DumpWorksheet(parent_workbook=self, title=title)
        else:
            if title is not None:
                new_ws = Worksheet(parent_workbook=self, title=title)
            else:
                new_ws = Worksheet(parent_workbook=self)

        self.add_sheet(worksheet=new_ws, index=index)
        return new_ws
Exemplo n.º 3
0
    def __init__(self, optimized_write=False, encoding='utf-8'):
        self.worksheets = []
        self._active_sheet_index = 0
        self._named_ranges = []
        self.properties = DocumentProperties()
        self.style = Style()
        self.security = DocumentSecurity()
        self.__optimized_write = optimized_write
        self.__optimized_read = False
        self.__thread_local_data = threading.local()
        self.strings_table_builder = StringTableBuilder()
        self.loaded_theme = None

        self.encoding = encoding

        if not optimized_write:
            self.worksheets.append(Worksheet(self))