原創|行業資訊|編輯:胡濤|2024-05-11 11:04:52.910|閱讀 95 次
概述:今天我們將深入探討我們的報告如何與 Node Schedule 作業調度程序集成。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
我們最近發布了一篇關于使用自動執行報告任務的文章。繼續這個主題,今天我們將深入探討我們的報告如何與 Node Schedule 作業調度程序集成。
Stimulsoft Ultimate (原Stimulsoft Reports.Ultimate)是用于創建報表和儀表板的通用工具集。該產品包括用于WinForms、ASP.NET、.NET Core、JavaScript、WPF、PHP、Java和其他環境的完整工具集。無需比較產品功能,Stimulsoft Ultimate包含了所有內容!
Node Schedule 是 Node.js 的靈活作業調度程序,按 cron 語法運行。它執行任務,允許基于時間而不是間隔的可選重復規則。節點計劃可用于各種目的,例如發送報告電子郵件、進行例行數據庫維護或執行定期數據分析任務。
我們的第一步是在 JavaScript 平臺上建立一個項目。為此,我們將使用JS 報告工具(完全用 JavaScript 開發的各種報告組件)。通過簡單安裝相應的npm 包,可以將該工具集成到自定義應用程序中。
要使用報告,我們需要stimulsoft-reports-js包,對于儀表板 - stimulsoft-dashboards-js。
此外,要添加和使用調度程序,您應該安裝包。
讓我們直接進入本文的要點。我們選擇將報告導出為 PDF 作為示例任務。接下來,我們將導出配置為每天 10:00 執行。
// Node Schedule module var schedule = require("node-schedule"); console.log("Node Schedule loaded"); // Stimulsoft Reports module var Stimulsoft = require("stimulsoft-reports-js"); console.log("Stimulsoft Reports loaded"); // Creating new report var report = new Stimulsoft.Report.StiReport(); console.log("New report created"); // Loading report template report.loadFile("SimpleList.mrt"); console.log("Report template loaded"); // Run the task every day at 10:00 var rule = new schedule.RecurrenceRule(); rule.hour = 10; rule.minute = 0; console.log("Rule for the task created"); // Scheduling the task schedule.scheduleJob(rule, function () { // Renreding report report.renderAsync(() => { console.log("Report rendered. Pages count: ", report.renderedPages.count); // Export to PDF report.exportDocumentAsync((pdfData) => { // Converting Array into buffer var buffer = Buffer.from(pdfData); // File System module var fs = require("fs"); // Saving string with rendered report in PDF into a file fs.writeFileSync("./SimpleList.pdf", buffer); console.log("Rendered report saved into PDF-file."); }, Stimulsoft.Report.StiExportFormat.Pdf); }); });
我們通過一個例子演示了自動化過程。從現在起,報告將在每天 10:00 轉換為 PDF 文件并保存到磁盤。
想要了解Stimulsoft Reports 報價信息的朋友,歡迎咨詢。
加入官方社群 740060302,歡迎相互交流
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn