示例#1
0
文件: xls.py 项目: daleathan/pyspread
    def xls_width2pys_width(self, xls_width):
        """Returns pyspread width from given xls width"""

        width_0 = get_default_text_extent("0")[0]
        width_0_char = xls_width / 256.0
        # Scale relative to 10 point font instead of 12 point
        return width_0_char * width_0 / 1.2
示例#2
0
文件: xls.py 项目: daleathan/pyspread
    def pys_width2xls_width(self, pys_width):
        """Returns xls width from given pyspread width"""

        width_0 = get_default_text_extent("0")[0]
        # Scale relative to 12 point font instead of 10 point
        width_0_char = pys_width * 1.2 / width_0
        return int(width_0_char * 256.0)
示例#3
0
    def xls_width2pys_width(self, xls_width):
        """Returns pyspread width from given xls width"""

        width_0 = get_default_text_extent("0")[0]
        width_0_char = xls_width / 256.0
        # Scale relative to 10 point font instead of 12 point
        return width_0_char * width_0 / 1.2
示例#4
0
    def pys_width2xls_width(self, pys_width):
        """Returns xls width from given pyspread width"""

        width_0 = get_default_text_extent("0")[0]
        # Scale relative to 12 point font instead of 10 point
        width_0_char = pys_width * 1.2 / width_0
        return int(width_0_char * 256.0)
示例#5
0
    def _xls2col_widths(self, worksheet, tab):
        """Updates col_widths in code_array"""

        for col in xrange(worksheet.ncols):
            try:
                width_0_char = worksheet.colinfo_map[col].width / 256.0
                width_0 = get_default_text_extent("0")[0]
                # Scale relative to 10 point font instead of 12 point
                width_pixels = width_0_char * width_0 / 1.2

                self.code_array.col_widths[col, tab] = width_pixels

            except KeyError:
                pass
示例#6
0
    def _xls2col_widths(self, worksheet, tab):
        """Updates col_widths in code_array"""

        for col in xrange(worksheet.ncols):
            try:
                width_0_char = worksheet.colinfo_map[col].width / 256.0
                width_0 = get_default_text_extent("0")[0]
                # Scale relative to 10 point font instead of 12 point
                width_pixels = width_0_char * width_0 / 1.2

                self.code_array.col_widths[col, tab] = width_pixels

            except KeyError:
                pass
示例#7
0
    def _col_widths2xls(self, worksheets):
        """Writes col_widths to xls file

        Format: <col>\t<tab>\t<value>\n

        """

        xls_max_cols, xls_max_tabs = self.xls_max_cols, self.xls_max_tabs

        dict_grid = self.code_array.dict_grid

        for col, tab in dict_grid.col_widths:
            if col < xls_max_cols and tab < xls_max_tabs:
                width_0 = get_default_text_extent("0")[0]
                width_pixels = dict_grid.col_widths[(col, tab)]
                width_0_char = width_pixels * 1.2 / width_0

                worksheets[tab].col(col).width_mismatch = True
                worksheets[tab].col(col).width = int(width_0_char * 256.0)
示例#8
0
    def _col_widths2xls(self, worksheets):
        """Writes col_widths to xls file

        Format: <col>\t<tab>\t<value>\n

        """

        xls_max_cols, xls_max_tabs = self.xls_max_cols, self.xls_max_tabs

        dict_grid = self.code_array.dict_grid

        for col, tab in dict_grid.col_widths:
            if col < xls_max_cols and tab < xls_max_tabs:
                width_0 = get_default_text_extent("0")[0]
                width_pixels = dict_grid.col_widths[(col, tab)]
                width_0_char = width_pixels * 1.2 / width_0

                worksheets[tab].col(col).width_mismatch = True
                worksheets[tab].col(col).width = int(width_0_char * 256.0)