Skip to content

Excel Based Printouts Integration Guide

This guide explains how to integrate Excel-based printouts into your Merciglobal Cloud ERP implementation. It is intended for internal developers, customers customizing their modules, or sales consultants preparing for client demonstrations.


Purpose

To generate PDF printouts from Excel templates dynamically using a custom JavaScript function. This is ideal for:

  • Invoices, Purchase Orders, Delivery Challans
  • Custom Formatted Reports
  • Documents with strict Excel formatting requirements

Integration Steps

1. Add JavaScript Function in <project>_core.js

Insert the following code in your project’s core JS file:

function yourown_func_name_in_jsfile_printDoc(table, id) {
   var xlsfile = '{printfilename}.xlsx';

   u.alert.showLoader({
      animationUrl: "/apis/js/lottieFiles/loader.json",
      backgroundColor: "#FFA000"
   });

   $.ajax({
      type: "POST",
      url: "/apis/ajax.php",
      data: ({
         func: "xlsxprint",
         table,
         xlsfile,
         id,
         mode: 'print',
         reqdXlsoutput: 0
      }),
      cache: false,
      async: true,
      success: function(res) {
         u.alert.hideLoader({});
         var data = JSON.parse(res);
         if (data.result == 'success') {
            window.open(data.pdf_file, '_blank');
         } else {
            u.alert.showError({ msg: data.reason, showAnimation: false });
         }
      }
   });
}

Parameters Explained

Parameter Description
table The database table where the source document is stored
id Unique document ID in the table
xlsfile Excel template file name
mode Static value 'print' for generating PDF
reqdXlsoutput 0 = No XLS, 1 = Output XLS too (optional functionality)

Expected Output

  • Loader animation is shown while the request is processed
  • If successful, a PDF will open in a new tab
  • In case of failure, an error message is displayed to the user

Usage Scenarios

  • Automating document generation using ERP data
  • Ensuring client-compliant layouts and print designs
  • Enhancing presentation value for official documents

Excel Template Preparation Tips

  • Use {column_name} placeholders to map database fields
  • Ensure proper formatting and layout using Excel styles
  • Keep a copy of templates in the /print_templates/ directory

Internal Notes (For Merci Developers)

  • Endpoint /apis/ajax.php must support func: xlsxprint
  • Ensure server has correct read/write permissions on print_templates
  • Templates must be pre-uploaded and version-controlled
  • Consider caching common templates for performance boost