Exemplo n.º 1
0
Arquivo: Row.py Projeto: kombinat/xlwt
 def write(self, col, label, style=Style.default_style):
     self.__adjust_height(style)
     self.__adjust_bound_col_idx(col)
     style_index = self.__parent_wb.add_style(style)
     if isinstance(label, basestring):
         if len(label) > 0:
             self.insert_cell(
                 col,
                 StrCell(self.__idx, col, style_index,
                         self.__parent_wb.add_str(label)))
         else:
             self.insert_cell(col, BlankCell(self.__idx, col, style_index))
     elif isinstance(label,
                     bool):  # bool is subclass of int; test bool first
         self.insert_cell(col,
                          BooleanCell(self.__idx, col, style_index, label))
     elif isinstance(label, (float, int, long, Decimal)):
         self.insert_cell(col,
                          NumberCell(self.__idx, col, style_index, label))
     elif isinstance(label, (dt.datetime, dt.date, dt.time)):
         date_number = self.__excel_date_dt(label)
         self.insert_cell(
             col, NumberCell(self.__idx, col, style_index, date_number))
     elif label is None:
         self.insert_cell(col, BlankCell(self.__idx, col, style_index))
     elif isinstance(label, ExcelFormula.Formula):
         self.__parent_wb.add_sheet_reference(label)
         self.insert_cell(col,
                          FormulaCell(self.__idx, col, style_index, label))
     elif isinstance(label, (list, tuple)):
         self.__rich_text_helper(col, label, style, style_index)
     else:
         raise Exception("Unexpected data type %r" % type(label))
Exemplo n.º 2
0
Arquivo: Row.py Projeto: kombinat/xlwt
 def set_cell_date(self, colx, datetime_obj, style=Style.default_style):
     self.__adjust_height(style)
     self.__adjust_bound_col_idx(colx)
     xf_index = self.__parent_wb.add_style(style)
     self.insert_cell(
         colx,
         NumberCell(self.__idx, colx, xf_index,
                    self.__excel_date_dt(datetime_obj)))
Exemplo n.º 3
0
Arquivo: Row.py Projeto: kombinat/xlwt
 def set_cell_number(self, colx, number, style=Style.default_style):
     self.__adjust_height(style)
     self.__adjust_bound_col_idx(colx)
     xf_index = self.__parent_wb.add_style(style)
     self.insert_cell(colx, NumberCell(self.__idx, colx, xf_index, number))