示例#1
0
 def write(self, col, label, style):
     self.__adjust_height(style)
     self.__adjust_bound_col_idx(col)
     if isinstance(label, (str, unicode)):
         if len(label) > 0:
             self.__cells.extend([
                 Cell.StrCell(self, col, self.__parent_wb.add_style(style),
                              self.__parent_wb.add_str(label))
             ])
             self.__total_str += 1
         else:
             self.__cells.extend([
                 Cell.BlankCell(self, col,
                                self.__parent_wb.add_style(style))
             ])
     elif isinstance(label, type(None)):
         self.__cells.extend(
             [Cell.BlankCell(self, col, self.__parent_wb.add_style(style))])
     elif isinstance(label, (int, long, float)):
         self.__cells.extend([
             Cell.NumberCell(self, col, self.__parent_wb.add_style(style),
                             label)
         ])
     elif isinstance(label, (dt.datetime, dt.date, dt.time)):
         self.__cells.extend([
             Cell.NumberCell(self, col, self.__parent_wb.add_style(style),
                             self.__excel_date_dt(label))
         ])
     else:
         self.__cells.extend([
             Cell.FormulaCell(self, col, self.__parent_wb.add_style(style),
                              label)
         ])
示例#2
0
 def write_blanks(self, c1, c2, style):
     self.__adjust_height(style)
     self.__adjust_bound_col_idx(c1, c2)
     assert c1 <= c2, 'start column (%d) must preceed end column (%d)' % (
         c1, c2)
     if (c1 == c2):
         self.__cells.extend(
             [Cell.BlankCell(self, c1, self.__parent_wb.add_style(style))])
     else:
         self.__cells.extend([
             Cell.MulBlankCell(self, c1, c2,
                               self.__parent_wb.add_style(style))
         ])