Skip to main content

Python integration with Crystal Reports

Project description

crystalpy-barno

Python Integration with Crystal Report for Dynamic Output

Features

  • Connect Crystal Report with Python for dynamic output

Installation

To install this project, run the following command:

pip install crystalpy-barno

Usage

Example Code

import os
from datetime import datetime

from crystalpy_barno.helpers.report_loader_helper import CrystalReportsLoader
from crystalpy_barno.config.database_config import DatabaseConfig
from crystalpy_barno.entry_point import generate_report

# Set database connection details externally
DatabaseConnectionHelper.set_connection_details(
    server_name="SERVER_NAME",
    database_name="DB_NAME",
    user_id="USER",
    password="PASS"
)

voucher_no = "VOUCHER_NO"
pdf_dir = os.path.join(cwd, 'pdf')
pdf_dir_sales = os.path.join(pdf_dir, 'sales')
pdf_filepath_sale = os.path.join(pdf_dir_sales, f"{voucher_no}.pdf")

# Generate a report
generate_report(
    report_type="sale_memo",
    filename='rpt/Sale_Memo_IncludeMaking.rpt',
    output_path=pdf_filepath_sale,
    parameters={
        "@pvSourcerecNo": '2425SOEBAR02135',
        "@pvVoucherNo": "2425SOPBAR00778",
        "@pvLeCode": "NJ",
        "@pvUserCode": "NIM",
        "@pvReportID": 1,
        "@pvIncludingMaking": "1",
    },
    formulas={
        "EmployeeName": "John Doe",
        "ReportCaption": "Sales Report"
    },
    file_type="pdf"
)

Report Generation

This code generates a sales memo report using the SaleMemo function from the SaleSnippet module. The report is generated based on the provided parameters and saved as a PDF file in the specified output path.

Database Connection

The database connection details are set externally using the DatabaseConnectionHelper class. You need to replace the placeholders with your actual database connection details.

Report Templates

The report template used in this example is Sale_Memo_IncludeMaking.rpt. You can modify this template or use a different one to suit your reporting needs.

Output Directory

The output directory for the generated report is specified using the pdf_dir variable. You can modify this to change the output directory.

Contributing

Contributions are welcome! Please submit a pull request with your changes and a brief description of what you've added or fixed.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crystalpy_barno-1.1.16.tar.gz (459.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crystalpy_barno-1.1.16-py3-none-any.whl (459.6 kB view details)

Uploaded Python 3

File details

Details for the file crystalpy_barno-1.1.16.tar.gz.

File metadata

  • Download URL: crystalpy_barno-1.1.16.tar.gz
  • Upload date:
  • Size: 459.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for crystalpy_barno-1.1.16.tar.gz
Algorithm Hash digest
SHA256 8c38d490bd742348a7d533ac163f6a00b9a4945f2417b211b5c3f9e85071b36e
MD5 9e18213e48763d7d663a0ac53bcf50c2
BLAKE2b-256 4f87ca1a209ffe0770ea83940648cb3c4ef040bd09acb1cc3ca2c91af537fc4f

See more details on using hashes here.

File details

Details for the file crystalpy_barno-1.1.16-py3-none-any.whl.

File metadata

File hashes

Hashes for crystalpy_barno-1.1.16-py3-none-any.whl
Algorithm Hash digest
SHA256 859ae66615ea822d306e7b6f965fd6c43661830a2e366ea655c7b3a112b6033a
MD5 b0cab92713bc31fa9dedd99ae91b509a
BLAKE2b-256 2a9ff1fb4083027370cc3ad233c84b6f0f827e826b19c77e6039d18de9c248f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page