def sheet(self,rdsheet,wtsheet_name): self.rdsheet = rdsheet; self.wtsheet_name = wtsheet_name; if self.__sheetIndex > 0 and self.__mvIndex > 0: myIndex=self.sheetIndex(rdsheet.name); if myIndex == self.__mvIndex: if self.__pading_sheet is None: self.__pading_sheet = self.rdbook.sheet_by_name(self.__rdSheetName); BaseWriter.sheet(self, self.__pading_sheet, self.__rdSheetName); for row_x in xrange(self.__pading_sheet.nrows): BaseWriter.row(self, row_x,row_x); for col_x in xrange(self.__pading_sheet.row_len(row_x)): BaseWriter.cell(self, row_x,col_x,row_x,col_x); BaseWriter.sheet(self,rdsheet,wtsheet_name); elif self.__rdSheetName == rdsheet.name: self.__pading_sheet = rdsheet; # 复制sheet,并更改复制的位置 if self.__option == 2: BaseWriter.sheet(self, self.__pading_sheet, self.__wtSheetname); else: BaseWriter.sheet(self,rdsheet,wtsheet_name); else: if self.__rdSheetName == rdsheet.name: self.__pading_sheet = rdsheet; # 删除sheet if self.__option < 3 or self.__rdSheetName != rdsheet.name: BaseWriter.sheet(self,rdsheet,wtsheet_name); # 复制sheet if self.__option == 2 and rdsheet.name == self.rdbook.sheet_by_index(-1).name: BaseWriter.sheet(self, self.__pading_sheet, self.__wtSheetname); for row_x in xrange(self.__pading_sheet.nrows): BaseWriter.row(self, row_x,row_x); for col_x in xrange(self.__pading_sheet.row_len(row_x)): BaseWriter.cell(self, row_x,col_x,row_x,col_x);
def cell(self,rdrowx,rdcolx,wtrowx,wtcolx): if self.rdsheet.name == self.__rdSheetName: # 插入cell if self.__option: # 横向增加区域 if self.__way: # 操作的单元格在区间内 if rdcolx >= self.__n_cells[1] and self.__n_cells[0] <= rdrowx < self.__n_cells[2]: BaseWriter.cell(self,rdrowx,rdcolx,wtrowx,wtcolx+self.__n_col); else: BaseWriter.cell(self,rdrowx,rdcolx,wtrowx,wtcolx); # 纵向增加区域 else: # 操作的单元格在区间内 if rdrowx >= self.__n_cells[0] and self.__n_cells[1] <= rdcolx < self.__n_cells[3]: BaseWriter.cell(self,rdrowx,rdcolx,wtrowx+self.__n_row,wtcolx); else: BaseWriter.cell(self,rdrowx,rdcolx,wtrowx,wtcolx); # 删除cell else: # 横向删减区域 if self.__way: # 操作的单元格在区间内 if rdcolx >= self.__n_cells[3] and self.__n_cells[0] <= rdrowx < self.__n_cells[2]: BaseWriter.cell(self,rdrowx,rdcolx,wtrowx,wtcolx-self.__n_col); elif self.__n_cells[1] <= rdcolx < self.__n_cells[3] and self.__n_cells[0] <= rdrowx < self.__n_cells[2]: pass; else: BaseWriter.cell(self,rdrowx,rdcolx,wtrowx,wtcolx); # 纵向增加区域 else: # 操作的单元格在区间内 if rdrowx >= self.__n_cells[2] and self.__n_cells[1] <= rdcolx < self.__n_cells[3]: BaseWriter.cell(self,rdrowx,rdcolx,wtrowx-self.__n_row,wtcolx); pass; elif self.__n_cells[1]<= rdcolx < self.__n_cells[3] and self.__n_cells[0] <= rdrowx < self.__n_cells[2]: pass; else: BaseWriter.cell(self,rdrowx,rdcolx,wtrowx,wtcolx); else: BaseWriter.cell(self,rdrowx,rdcolx,wtrowx,wtcolx);