Example #1
0
def get_writer(format):
    try:
        return {
            Format.CSV: writers.CsvExportWriter,
            Format.HTML: writers.HtmlExportWriter,
            Format.ZIPPED_HTML: writers.ZippedHtmlExportWriter,
            Format.JSON: writers.JsonExportWriter,
            Format.XLS: writers.Excel2003ExportWriter,
            Format.XLS_2007: writers.Excel2007ExportWriter,
            Format.UNZIPPED_CSV: writers.UnzippedCsvExportWriter,
        }[format]()
    except KeyError:
        raise UnsupportedExportFormat("Unsupported export format: %s!" %
                                      format)
Example #2
0
def get_writer(format, use_formatted_cells=False):
    if format == Format.XLS_2007:
        return writers.Excel2007ExportWriter(
            use_formatted_cells=use_formatted_cells)
    try:
        return {
            Format.CSV: writers.CsvExportWriter,
            Format.HTML: writers.HtmlExportWriter,
            Format.ZIPPED_HTML: writers.ZippedHtmlExportWriter,
            Format.JSON: writers.JsonExportWriter,
            Format.XLS: writers.Excel2003ExportWriter,
            Format.UNZIPPED_CSV: writers.UnzippedCsvExportWriter,
            Format.PYTHON_DICT: writers.PythonDictWriter,
        }[format]()
    except KeyError:
        raise UnsupportedExportFormat("Unsupported export format: %s!" %
                                      format)