def __appendAutoFilterNode(self, wb, baseNode): if len(self.__autoFilterArrows) <= 0: # No autofilter in this sheet. return wbg = wb.getWorkbookGlobal() tokens = wbg.getFilterRange(self.__sheetID) parser = formula.FormulaParser(None, tokens) parser.parse() tokens = parser.getTokens() if len(tokens) != 1 or tokens[0].tokenType != formula.TokenType.Area3d: # We assume that the database range only has one range token, otherwise # we bail out. return tk = tokens[0] cellRange = tk.cellRange elem = baseNode.appendElement('autofilter') elem.setAttr('range', cellRange.getName()) for i in xrange(0, len(self.__autoFilterArrows)): arrowObj = self.__autoFilterArrows[i] if arrowObj == None: arrow = elem.appendElement('arrow') cell = formula.CellAddress(cellRange.firstCol + i, cellRange.firstRow) arrow.setAttr('pos', cell.getName()) else: elem.appendChild(arrowObj.createDOM(wb, cellRange))
def createDOM(self, wb, filterRange): nd = node.Element('arrow') col = self.filterID + filterRange.firstCol row = filterRange.firstRow cell = formula.CellAddress(col, row) nd.setAttr('pos', cell.getName()) nd.setAttr('active', self.isActive) eqStr = '' if self.equalString1 != None: eqStr = self.equalString1 if self.equalString2 != None: eqStr += ',' + self.equalString2 nd.setAttr('equals', eqStr) return nd
def setFirstFreeCell(self, col, row): self.__firstFreeCell = formula.CellAddress(col, row)
def setFirstDefinedCell(self, col, row): self.__firstDefinedCell = formula.CellAddress(col, row)