Usage
npm i @icreate/ics-chromely-plugin-report-js-sdk
Features
0.0.9-beta.1 注册数据源时允许指定字段类型
0.0.9 优化和完善导出pdf流
0.0.8-beta.1 增加导出pdf流示例
0.0.8 增加导出pdf流支持
0.0.7 修复打印和准备打印方法调用不传打印机名称时使用默认打印机
0.0.6 修改print和printPrepared的printerName允许为空
0.0.5 增加打印准备报表printPrepared
0.0.4 增加预览准备报表showPrepared
0.0.3 将注册数据源数据转为为json字符串
Importing library
You can import the generated bundle to use the whole library generated by this starter:
import ReportHelper from '@icreate/ics-chromely-plugin-report-js-sdk'
ReportHelper
load(fileName: string): Promise<any>
loadFromId(reportId: string): Promise<any>
clearData(): Promise<any>
registerData(name: string, data: Array<any>): Promise<any>
doublePass(value: Boolean): Promise<any>
prepare(append: Boolean): Promise<any>
addParameter(name: string, value: string): Promise<any>
design(): Promise<any>
show(): Promise<any>
showPrepared(): Promise<any>
print(printerName?: string): Promise<any>
printPrepared(printerName?: string): Promise<any>
ExportToPdf(fileName: string): Promise<any>
exportToHtml(fileName: string): Promise<any>
dispose(): Promise<any>
一般设计打印示例
const reportHelper = new ReportHelper()
await reportHelper.clearData()
await reportHelper.load('xxxx.frx')
await reportHelper.registerData('患者基本信息',[{ id:"1",name:"张三"}])
await reportHelper.design()
await reportHelper.show()
await reportHelper.print()
指定字段类型示例
const reportHelper = new ReportHelper()
await reportHelper.clearData()
await reportHelper.load('xxxx.frx')
await reportHelper.registerData('患者基本信息',[{ id:"1",name:"张三",birthday:"1988-05-26"}],{id:"string",name:"string", birthday: "date"})
await reportHelper.design()
await reportHelper.show()
await reportHelper.print()
字段类型说明
类型 | 描述 | 范围 | 默认值 |
---|
bool | 布尔值 | True 或 False | FALSE |
byte | 8 位无符号整数 | 0 到 255 | 0 |
char | 16 位 Unicode 字符 | U +0000 到 U +ffff | '\0' |
decimal | 128 位精确的十进制值,28-29 有效位数 | (-7.9 x 1028 到 7.9 x 1028) / 100 到 28 | 0.0M |
double | 64 位双精度浮点型 | (+/-)5.0 x 10-324 到 (+/-)1.7 x 10308 | 0.0D |
float | 32 位单精度浮点型 | -3.4 x 1038 到 + 3.4 x 1038 | 0.0F |
int | 32 位有符号整数类型 | -2,147,483,648 到 2,147,483,647 | 0 |
long | 64 位有符号整数类型 | -9,223,372,036,854,775,808 到 9,223,372,036,854,775,807 | 0L |
sbyte | 8 位有符号整数类型 | -128 到 127 | 0 |
short | 16 位有符号整数类型 | -32,768 到 32,767 | 0 |
uint | 32 位无符号整数类型 | 0 到 4,294,967,295 | 0 |
ulong | 64 位无符号整数类型 | 0 到 18,446,744,073,709,551,615 | 0 |
ushort | 16 位无符号整数类型 | 0 到 65,535 | 0 |
date | 日期 | 0001/1/1 00:00:00到9999/12/31 00:00:00之间 | 0001/1/1 0:00:00 |
datetime | 日期时间 | 0001/1/1 00:00:00到9999/12/31 23:59:59之间 | 0001/1/1 0:00:00 |
合并打印示例
const reportHelper = new ReportHelper()
await reportHelper.clearData()
await reportHelper.load('xxxx.frx')
await reportHelper.registerData('患者基本信息',[{ id:"1",name:"张三"}])
await reportHelper.prepare(false)
await reportHelper.clearData()
await reportHelper.load('xxxx.frx')
await reportHelper.registerData('患者基本信息',[{ id:"1",name:"李四"}])
await reportHelper.prepare(true)
await reportHelper.showPrepared()
await reportHelper.printPrepared()
导出pdf流示例
const reportHelper = new ReportHelper()
await reportHelper.clearData()
await reportHelper.load('xxxx.frx')
await reportHelper.registerData('患者基本信息', [
{ id: '1', name: '张三' }
])
await reportHelper.prepare(true)
const blob = await reportHelper.ExportToPdf()
const source = await blob.arrayBuffer()
console.log(source, 'arrayBuffer')
const source = URL.createObjectURL(blob)
console.log(source, 'url')