示例#1
0
def iter_rows(workbook_name, sheet_name, xml_source, range_string='', row_offset=0, column_offset=0):

    archive = get_archive_file(workbook_name)

    source = xml_source

    if range_string:
        min_col, min_row, max_col, max_row = get_range_boundaries(range_string, row_offset, column_offset)
    else:
        min_col, min_row, max_col, max_row = read_dimension(xml_source=source)
        min_col = column_index_from_string(min_col)
        max_col = column_index_from_string(max_col) + 1
        max_row += 6

    try:
        string_table = read_string_table(archive.read(ARC_SHARED_STRINGS))
    except KeyError:
        string_table = {}

    style_table = read_style_table(archive.read(ARC_STYLE))

    source.seek(0)
    p = iterparse(source)

    return get_squared_range(p, min_col, min_row, max_col, max_row, string_table, style_table)
示例#2
0
def iter_rows(workbook_name,
              sheet_name,
              xml_source,
              shared_date,
              string_table,
              range_string='',
              row_offset=0,
              column_offset=0):

    archive = get_archive_file(workbook_name)

    source = xml_source

    if range_string:
        min_col, min_row, max_col, max_row = get_range_boundaries(
            range_string, row_offset, column_offset)
    else:
        min_col, min_row, max_col, max_row = read_dimension(xml_source=source)
        min_col = column_index_from_string(min_col)
        max_col = column_index_from_string(max_col) + 1
        max_row += 6

    style_table = read_style_table(archive.read(ARC_STYLE))

    source.seek(0)
    p = iterparse(source)

    return get_squared_range(p, min_col, min_row, max_col, max_row,
                             string_table, style_table, shared_date)
示例#3
0
def test_read_dimension():

    path = os.path.join(DATADIR, 'reader', 'sheet2.xml')

    with open(path) as handle:

        dimension = read_dimension(xml_source = handle.read())

    eq_(('D', 1, 'K', 30), dimension)
示例#4
0
def test_read_dimension():

    path = os.path.join(DATADIR, 'reader', 'sheet2.xml')

    with open(path) as handle:

        dimension = read_dimension(xml_source=handle.read())

    eq_(('D', 1, 'K', 30), dimension)
示例#5
0
def test_read_dimension():

    path = os.path.join(DATADIR, "reader", "sheet2.xml")

    dimension = None
    handle = open(path)
    try:
        dimension = read_dimension(xml_source=handle.read())
    finally:
        handle.close()

    eq_(("D", 1, "K", 30), dimension)
def test_read_dimension():

    path = os.path.join(DATADIR, 'reader', 'sheet2.xml')

    dimension = None
    handle = open(path)
    try:
        dimension = read_dimension(xml_source=handle.read())
    finally:
        handle.close()

    eq_(('D', 1, 'K', 30), dimension)
示例#7
0
def test_read_dimension():

    path = os.path.join(DATADIR, 'reader', 'sheet2.xml')

    dimension = None
    handle = open(path)
    try:
        dimension = read_dimension(xml_source=handle.read())
    finally:
        handle.close()

    eq_(('D', 1, 'K', 30), dimension)
示例#8
0
    def __init__(self, parent_workbook, title, workbook_name,
            sheet_codename, xml_source):

        Worksheet.__init__(self, parent_workbook, title)
        self._workbook_name = workbook_name
        self._sheet_codename = sheet_codename
        self._xml_source = xml_source

        min_col, min_row, max_col, max_row = read_dimension(xml_source=xml_source)

        self._max_row = max_row
        self._max_column = max_col
        self._dimensions = '%s%s:%s%s' % (min_col, min_row, max_col, max_row)
示例#9
0
    def __init__(self, parent_workbook, title, worksheet_path,
                 xml_source, string_table, style_table):
        Worksheet.__init__(self, parent_workbook, title)
        self.worksheet_path = worksheet_path
        self._string_table = string_table
        self._style_table = style_table

        min_col, min_row, max_col, max_row = read_dimension(xml_source=self.xml_source)
        self.min_col = min_col
        self.min_row = min_row
        self.max_row = max_row
        self.max_col = max_col

        self._shared_date = SharedDate(base_date=parent_workbook.excel_base_date)
示例#10
0
    def __init__(self, parent_workbook, title, workbook_name, sheet_codename,
                 xml_source):

        Worksheet.__init__(self, parent_workbook, title)
        self._workbook_name = workbook_name
        self._sheet_codename = sheet_codename
        self._xml_source = xml_source

        min_col, min_row, max_col, max_row = read_dimension(
            xml_source=xml_source)

        self._max_row = max_row
        self._max_column = max_col
        self._dimensions = '%s%s:%s%s' % (min_col, min_row, max_col, max_row)
示例#11
0
    def __init__(self, parent_workbook, title, workbook_name,
            sheet_codename, xml_source, string_table):

        Worksheet.__init__(self, parent_workbook, title)
        self.archive = zipfile.ZipFile(workbook_name, 'r')
        self._workbook_name = workbook_name
        self._sheet_codename = sheet_codename
        self._string_table = string_table

        min_col, min_row, max_col, max_row = read_dimension(xml_source=self.xml_source)
        self.min_col = min_col
        self.min_row = min_row
        self.max_row = max_row
        self.max_col = max_col

        self._shared_date = SharedDate(base_date=parent_workbook.excel_base_date)
    def __init__(self, parent_workbook, title, workbook_name,
            sheet_codename, xml_source, string_table):

        Worksheet.__init__(self, parent_workbook, title)
        self._workbook_name = workbook_name
        self._sheet_codename = sheet_codename
        self._xml_source = xml_source
        self._string_table = string_table

        min_col, min_row, max_col, max_row = read_dimension(xml_source=xml_source)

        self._max_row = max_row
        self._max_column = max_col
        self._dimensions = '%s%s:%s%s' % (min_col, min_row, max_col, max_row)

        self._shared_date = SharedDate(base_date=parent_workbook.excel_base_date)
示例#13
0
    def __init__(self, parent_workbook, title, sheet_codename, xml_source,
                 string_table, style_table):

        Worksheet.__init__(self, parent_workbook, title)
        self._sheet_codename = sheet_codename
        self._string_table = string_table
        self._style_table = style_table

        min_col, min_row, max_col, max_row = read_dimension(
            xml_source=self.xml_source)
        self.min_col = min_col
        self.min_row = min_row
        self.max_row = max_row
        self.max_col = max_col

        self._shared_date = SharedDate(
            base_date=parent_workbook.excel_base_date)
示例#14
0
    def __init__(self, parent_workbook, title, workbook_name, sheet_codename,
                 xml_source, string_table):

        Worksheet.__init__(self, parent_workbook, title)
        self._workbook_name = workbook_name
        self._sheet_codename = sheet_codename
        self._xml_source = xml_source
        self._string_table = string_table

        min_col, min_row, max_col, max_row = read_dimension(
            xml_source=xml_source)

        self._max_row = max_row
        self._max_column = max_col
        self._dimensions = '%s%s:%s%s' % (min_col, min_row, max_col, max_row)

        self._shared_date = SharedDate(
            base_date=parent_workbook.excel_base_date)
def iter_rows(workbook_name, sheet_name, xml_source, shared_date, string_table, range_string='', row_offset=0, column_offset=0):

    archive = get_archive_file(workbook_name)

    source = xml_source

    if range_string:
        min_col, min_row, max_col, max_row = get_range_boundaries(range_string, row_offset, column_offset)
    else:
        min_col, min_row, max_col, max_row = read_dimension(xml_source=source)
        min_col = column_index_from_string(min_col)
        max_col = column_index_from_string(max_col) + 1
        max_row += 6

    style_properties = read_style_table(archive.read(ARC_STYLE))
    style_table = style_properties.pop('table')

    source.seek(0)
    p = iterparse(source)

    return get_squared_range(p, min_col, min_row, max_col, max_row, string_table, style_table, shared_date)
示例#16
0
def test_read_dimension(filename):
    path = os.path.join(DATADIR, "reader", filename)
    dimension = None
    with open(path) as handle:
        dimension = read_dimension(handle.read())
    assert dimension == ("D", 1, "AA", 30)
示例#17
0
def test_read_dimension(filename):
    path = os.path.join(DATADIR, 'reader', filename)
    dimension = None
    with open(path) as handle:
        dimension = read_dimension(handle.read())
    assert dimension == ('D', 1, 'AA', 30)
示例#18
0
def test_read_dimension(filename):
    path = os.path.join(DATADIR, 'reader', filename)
    dimension = None
    with open(path) as handle:
        dimension = read_dimension(handle.read())
    assert dimension == ('D', 1, 'AA', 30)