Changing Target File Format

Note
The example reads the shop data described in The Business Layer.

GroupDocs.Assembly provides a powerful feature to change the target file format of an assembled document using file extension or explicit specification. GroupDocs.Assembly API provides the ability to change target file format when assembling the following file formats:

  • Word Processing documents
  • Spreadsheet documents
  • Presentation documents
  • Email documents
  • Text documents

Supported output file formats depending on input file formats can be found at this page.

Changing Target File Format using File Extension

import json
from datetime import datetime

from groupdocs.assembly import DataSourceInfo, DocumentAssembler

def parse_dates(item):
    # JSON has no dates: turn the order dates into datetime objects for the template
    for key in ("OrderDate", "ShippingDate"):
        if key in item:
            item[key] = datetime.strptime(item[key], "%Y-%m-%dT%H:%M:%S")
    return item

with open("orders.json", encoding="utf-8") as f:
    orders = json.load(f, object_hook=parse_dates)

assembler = DocumentAssembler()
assembler.assemble_document("bubble-chart.docx", "bubble-chart-report.pdf", DataSourceInfo(orders, "orders"))

The following sample file is used in this example: bubble-chart.docx

The following sample file is used in this example: orders.json

Binary file (PDF, 44 KB)

Download full output

from groupdocs.assembly import DataSourceInfo, DocumentAssembler

assembler = DocumentAssembler()
assembler.assemble_document("conversion-template.pptx", "conversion-template-report.pptx", DataSourceInfo("Harbor Lane Provisions", "product"))

The following sample file is used in this example: conversion-template.pptx

Binary file (PPTX, 38 KB)

Download full output

from groupdocs.assembly import DataSourceInfo, DocumentAssembler

assembler = DocumentAssembler()
assembler.assemble_document("conversion-template.pot", "conversion-template-report.pot", DataSourceInfo("Harbor Lane Provisions", "product"))

The following sample file is used in this example: conversion-template.pot

Binary file (POT, 180 KB)

Download full output

from groupdocs.assembly import DataSourceInfo, DocumentAssembler

assembler = DocumentAssembler()
assembler.assemble_document("conversion-template.otp", "conversion-template-report.otp", DataSourceInfo("Harbor Lane Provisions", "product"))

The following sample file is used in this example: conversion-template.otp

Binary file (OTP, 7 KB)

Download full output

from groupdocs.assembly import DataSourceInfo, DocumentAssembler

assembler = DocumentAssembler()
assembler.assemble_document("conversion-template.xlsx", "conversion-template-report.xlsx", DataSourceInfo("Harbor Lane Provisions", "product"))

The following sample file is used in this example: conversion-template.xlsx

Binary file (XLSX, 9 KB)

Download full output

from groupdocs.assembly import DataSourceInfo, DocumentAssembler

assembler = DocumentAssembler()
assembler.assemble_document("conversion-template.xlt", "conversion-template-report.xlt", DataSourceInfo("Harbor Lane Provisions", "product"))

The following sample file is used in this example: conversion-template.xlt

Binary file (XLT, 14 KB)

Download full output

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.