def exportSheetToImage(self, fileName):
        (rCount, cCount) = self.getDimension()
        if rCount<1 or cCount<1: return
        cellHeights = [self.getCellRect(r, 0).height()
                       for r in xrange(rCount)]
        cellWidths = [self.getCellRect(0, c).width()
                      for c in xrange(cCount)]
        finalImage = QtGui.QImage(sum(cellWidths), sum(cellHeights), QtGui.QImage.Format_ARGB32)
        finalImage.fill(0xFFFFFFFF)
        painter = QtGui.QPainter(finalImage)
        y = 0
        for r in xrange(rCount):
            x = 0
            for c in xrange(cCount):
                widget = self.getCell(r, c)
                if widget:
                    pix = widget.grabWindowPixmap()
                    cx = (cellWidths[c]-pix.width())//2
                    cy = (cellHeights[r]-pix.height())//2
                    painter.drawPixmap(x+cx, y+cy, widget.grabWindowPixmap())
                x += cellWidths[c]
            y += cellHeights[r]
        painter.end()

        #forcing png format if no extension was provided
        (_,ext) = os.path.splitext(fileName)
        if ext == '':
            finalImage.save(fileName, 'png')
        else:
            #try to guess based on the extension
            finalImage.save(fileName)
exportSheetToImage() -> None
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/packages/spreadsheet/spreadsheet_tab.py/StandardWidgetSheetTabInterface.exportSheetToImage