<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def OnExport(self, event):
 """File export event handler Currently, only CSV export is supported """


        code_array = self.main_window.grid.code_array
        tab = self.main_window.grid.current_table

        selection = self.main_window.grid.selection

        # Check if no selection is present

        selection_bbox = selection.get_bbox()

        f2w = get_filetypes2wildcards(["csv", "pdf", "svg"])
        filters = f2w.keys()
        wildcards = f2w.values()

        wildcard = "|".join(wildcards)

        if selection_bbox is None:
            # No selection --> Use smallest filled area for bottom right edge
            maxrow, maxcol, __ = code_array.get_last_filled_cell(tab)

            (top, left), (bottom, right) = (0, 0), (maxrow, maxcol)

        else:
            (top, left), (bottom, right) = selection_bbox

        # Generator of row and column keys in correct order

        __top = 0 if top is None else top
        __bottom = code_array.shape[0] if bottom is None else bottom + 1
        __left = 0 if left is None else left
        __right = code_array.shape[1] if right is None else right + 1

        def data_gen(top, bottom, left, right):
            for row in xrange(top, bottom):
                yield (code_array[row, col, tab]
                       for col in xrange(left, right))

        data = data_gen(__top, __bottom, __left, __right)
        preview_data = data_gen(__top, __bottom, __left, __right)

        # Get target filepath from user

        # No selection --> Provide svg export of current cell
        # if current cell is a matplotlib figure
        if selection_bbox is None:
            cursor = self.main_window.grid.actions.cursor
            figure = code_array[cursor]
            if Figure is not None and isinstance(figure, Figure):
                wildcard += \
                    "|" + _("SVG of current cell") + " (*.svg)|*.svg" + \
                    "|" + _("EPS of current cell") + " (*.eps)|*.eps" + \
                    "|" + _("PS of current cell") + " (*.ps)|*.ps" + \
                    "|" + _("PDF of current cell") + " (*.pdf)|*.pdf" + \
                    "|" + _("PNG of current cell") + " (*.png)|*.png"
                filters.append("cell_svg")
                filters.append("cell_eps")
                filters.append("cell_ps")
                filters.append("cell_pdf")
                filters.append("cell_png")

        message = _("Choose filename for export.")
        style = wx.SAVE
        path, filterindex = \
            self.interfaces.get_filepath_findex_from_user(wildcard, message,
                                                          style)

        if path is None:
            return

        # If an single cell is exported then the selection bbox
        # has to be changed to the current cell
        if filters[filterindex].startswith("cell_"):
            data = figure

        # Export file
        # -----------

        self.main_window.actions.export_file(path, filters[filterindex], data,
                                             preview_data)