1. grid++ report selection template preview and automatic printing
This is mainly the front- end and back-end cooperation , data front-end incoming, and printing back-end configuration.
IGridppReport members:
The package is printed immediately, and the data format is:
{
"reportData": {
"fileName": "模板.grf",
"printerName": '打印机型号',
"jsonData": {}
}
}
try{
PipeData pdata = JsonHelper.ConvertJsonStringToObject<PipeData>(printParams);
dynamic reportData = pdata.reportData;
if (reportData== null) return;
var fileName = reportData["fileName"];
string data = JsonHelper.ConvertObjectToJsonString(reportData["jsonData"]);
string printerName = pdata.printerName.ToString();
if (string.IsNullOrEmpty(printerName))
printerName = GetDefaultPrintName();
if (string.IsNullOrEmpty(printerName)) return;
//...省略注册锐浪报表
var filePath = Path.Combine(GlobalData.ReportsFileFolder, fileName);
GridppReport Report = new GridppReport();
Report.LoadFromFile(filePath);
Report.Printer.PrintOffsetSaveToLocal = true;
Report.LoadDataFromXML(data);
//指定打印机
Report.Printer.PrinterName = printerName;
Report.Print(false)
WriteLog("打印:" + fileName);
}
catch (Exception e){
WriteLog("打印失败:" + e.Message);
}
2. Clodop preview and automatic printing
let LODOP = await getLodop();
//立即打印
LODOP.PRINT();
//预览、微调
LODOP.PRINT_SETUP();