如何新建的报表内置数据源和数据集
我们新建报表时,可能有时候想要带内置的数据源和数据集,可能设计人员并不懂数据库连接和sql信息,又或者不想他们操作这些内容,那怎么办,当然有办法了。我们用以下写法即可:
let ConnectString = "Driver={MySQL ODBC 8.0 Unicode Driver};Server=xa-irs-database;Port=3306;Database=test;User=root;Password=xA123456;Option=3;";
let sql = "select * from test";
let Templates = { "Name": "数据库模板.rdlx", "Width": "2pt", "DocumentMap": { "Source": "All" }, "Layers": [{ "Name": "default" }], "CustomProperties": [{ "Name": "DisplayType", "Value": "Page" }, { "Name": "SizeType", "Value": "Default" }, { "Name": "PaperOrientation", "Value": "Portrait" }], "Page": { "PageWidth": "21cm", "PageHeight": "29.7cm", "RightMargin": "2.5cm", "LeftMargin": "2.5cm", "TopMargin": "2.5cm", "BottomMargin": "2.5cm", "Columns": 1, "ColumnSpacing": "0.5in" }, "DataSources": [{ "Name": "DataSource1", "ConnectionProperties": { "DataProvider": "ODBC", "ConnectString": ConnectString } }], "Body": { "Height": "2pt" }, "DataSets": [{ "Name": "DataSet1", "Fields": [], "Query": { "DataSourceName": "DataSource1", "CommandText": sql }, "CaseSensitivity": "Auto", "KanatypeSensitivity": "Auto", "AccentSensitivity": "Auto", "WidthSensitivity": "Auto" }] }
GrapeCity.ActiveReports.WebDesigner.renderApplication("ar-web-designer").then((api) => {
var reportContent = Templates;
api.documents.openById('NewReport.rdlx', { platform: 'rdlx', type: 'report', subType: 'cpl' }, 'NewReport', reportContent).then((rep) => {
});
})
上述写法运行好后打开新建报表如下图所示
而实际用户每次只需要操作下面这步:
验证正常连接即可使用.
具体可以参考链接Demo
页:
[1]