telerik reporting 在.net core api 使用
工具要求:telerik reporting R3 2019、.net core 2.2 、vs2017 最新版
从官网下载下来的的telerik reporting 的.net core 例子是无法成功预览报表的,可能内部程序有问题,
以下为正确操作步骤
1.打开nuget 包管理源,新建程序包源(https://nuget.telerik.com/nuget),如下:

2.切换程序包源,选择telerik reporting 安装包,如下:

3.api代码:
namespace CSharp.AspNetCoreDemo.Controllers
{
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Telerik.Reporting.Services;
using Telerik.Reporting.Services.AspNetCore;
using System.Net;
using System.Net.Mail;
using Telerik.Reporting.Cache.File;
using Microsoft.AspNetCore.Authorization; [Route("api/reports")]
public class ReportsController : ReportsControllerBase
{
readonly string reportsPath = string.Empty; public ReportsController(ConfigurationService configSvc)
{ this.reportsPath = Path.Combine(configSvc.Environment.WebRootPath, "report"); this.ReportServiceConfiguration = new ReportServiceConfiguration
{
ReportingEngineConfiguration = configSvc.Configuration,
HostAppId = "Html5DemoAppCore",
Storage = new FileStorage(),
ReportResolver = new ReportTypeResolver()
.AddFallbackResolver(new ReportFileResolver(this.reportsPath)),
};
} [HttpGet("reportlist")]
public IEnumerable<string> GetReports()
{
//return Directory
// .GetFiles(this.reportsPath)
// .Select(path =>
// Path.GetFileName(path)); List<string> list = new List<string>(); foreach (var item in Directory.GetFiles(this.reportsPath))
{
var fileName= Path.GetFileName(item);
list.Add(fileName);
}
return list;
}
protected override HttpStatusCode SendMailMessage(MailMessage mailMessage)
{
throw new System.NotImplementedException("This method should be implemented in order to send mail messages");
//using (var smtpClient = new SmtpClient("smtp01.mycompany.com", 25))
//{
// smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
// smtpClient.EnableSsl = false; // smtpClient.Send(mailMessage);
//}
//return HttpStatusCode.OK;
} }
}
4:前端代码
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Telerik HTML5 Report Viewer Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <link href="http://kendo.cdn.telerik.com/2018.2.620/styles/kendo.common.min.css" rel="stylesheet" id="common-css" />
<link href="http://kendo.cdn.telerik.com/2018.2.620/styles/kendo.blueopal.min.css" rel="stylesheet" id="skin-css" /> <script src="/Scripts/themeSwitcher.js"></script> <script src="/api/reports/resources/js/telerikReportViewer"></script> <style>
body {
font-family: Verdana, Arial, sans-serif;
margin: 5px;
} #reportViewer1 {
position: absolute;
left: 5px;
right: 5px;
top: 40px;
bottom: 5px;
overflow: hidden;
clear: both;
} #theme-switcher {
float: right;
width: 12em;
height: 30px;
}
</style>
</head>
<body>
<select id="theme-switcher"></select> <div id="reportViewer1">
loading...
</div> <script type="text/javascript"> $(document).ready(function () {
//Theme switcher
themeSwitcher(
'#theme-switcher',
'#common-css',
'#skin-css'); $("#reportViewer1")
.telerik_ReportViewer({
// The URL of the service which will serve reports.
// The URL corresponds to the name of the controller class (ReportsController).
// For more information on how to configure the service please check http://www.telerik.com/help/reporting/telerik-reporting-rest-conception.html.
serviceUrl: "api/reports/", // The URL for the report viewer template. The template can be edited -
// new functionalities can be added and unneeded ones can be removed.
// For more information please check http://www.telerik.com/help/reporting/html5-report-viewer-templates.html.
// templateUrl: 'ReportViewer/templates/telerikReportViewerTemplate.html', //ReportSource - report description
reportSource: { // The report can be set to a report file name (.trdx or .trdp report definition)
// or CLR type name (report class definition).
report: "Report.trdp", // Parameters name value dictionary
//parameters: {}
}, //parameters: {
// editors: {
// singleSelect: telerikReportViewer.ParameterEditorTypes.COMBO_BOX,
// multiSelect: telerikReportViewer.ParameterEditorTypes.COMBO_BOX,
// }
//}, // Specifies whether the viewer is in interactive or print preview mode.
// PRINT_PREVIEW - Displays the paginated report as if it is printed on paper. Interactivity is not enabled.
// INTERACTIVE - Displays the report in its original width and height without paging. Additionally interactivity is enabled.
viewMode: telerikReportViewer.ViewModes.INTERACTIVE, // Sets the scale mode of the viewer.
// Three modes exist currently:
// FIT_PAGE - The whole report will fit on the page (will zoom in or out), regardless of its width and height.
// FIT_PAGE_WIDTH - The report will be zoomed in or out so that the width of the screen and the width of the report match.
// SPECIFIC - Uses the scale to zoom in and out the report.
scaleMode: telerikReportViewer.ScaleModes.SPECIFIC, // Zoom in and out the report using the scale
// 1.0 is equal to 100%, i.e. the original size of the report
scale: 1.0, //Enables or disables the accessibility features of the report viewer and its contents.
enableAccessibility: false, //If set to true shows the Send Mail Message toolbar button
sendEmail: { enabled: true }
});
});
</script> </body>
</html>
5. 本人使用的是oracle ,所以是引用Oracle.ManagedDataAccess.Core ,这个dll 不需要按照oracle 的客户端。配置文件添加数据库连接

6. 若是想在报表设计器预览 又不想安装oracle 客户端,操作如下:
1)修改设计器的Telerik.ReportDesigner.exe.config ,在connectionStrings 前添加以下内容
<system.data>
<DbProviderFactories>
<remove invariant="Oracle.ManagedDataAccess.Client" />
<!-- If any should be in the machine.config -->
<add name="Oracle.ManagedDataAccess" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral" />
</DbProviderFactories>
</system.data>
2)在设计器Telerik.ReportDesigner.exe同级目录放入:
Oracle.ManagedDataAccess.dll
源码 地址:https://download.csdn.net/download/h4715582/11956099
telerik reporting 在.net core api 使用的更多相关文章
- 修复Telerik reporting 在网页中使用时的样式
在ASP.NET 网页或ASP MVC中嵌入Telerik Reporting时,报表出来的样式是有问题的,按扭的位置错位了. 在页面中引入以下CSS文件可以将报表样式修复从而回到正常的报表样式. . ...
- AspNet Core Api Restful 实现微服务之旅 (一)
(一)了解微服务(二)搭建VS项目框架 (三)创建AspNet Core Api VS2017 安装包 链接:https://pan.baidu.com/s/1hsjGuJq 密码:ug59 创 ...
- 【从零开始搭建自己的.NET Core Api框架】(七)授权认证进阶篇
系列目录 一. 创建项目并集成swagger 1.1 创建 1.2 完善 二. 搭建项目整体架构 三. 集成轻量级ORM框架——SqlSugar 3.1 搭建环境 3.2 实战篇:利用SqlSuga ...
- .net core api +swagger(一个简单的入门demo 使用codefirst+mysql)
前言: 自从.net core问世之后,就一直想了解.但是由于比较懒惰只是断断续续了解一点.近段时间工作不是太忙碌,所以偷闲写下自己学习过程.慢慢了解.net core 等这些基础方面学会之后再用.n ...
- 【从零开始搭建自己的.NET Core Api框架】(一)创建项目并集成swagger:1.1 创建
系列目录 一. 创建项目并集成swagger 1.1 创建 1.2 完善 二. 搭建项目整体架构 三. 集成轻量级ORM框架——SqlSugar 3.1 搭建环境 3.2 实战篇:利用SqlSuga ...
- 【从零开始搭建自己的.NET Core Api框架】(四)实战!带你半个小时实现接口的JWT授权验证
系列目录 一. 创建项目并集成swagger 1.1 创建 1.2 完善 二. 搭建项目整体架构 三. 集成轻量级ORM框架——SqlSugar 3.1 搭建环境 3.2 实战篇:利用SqlSuga ...
- 详解ASP.NET Core API 的Get和Post请求使用方式
上一篇文章帮助大家解决问题不彻底导致博友使用的时候还是遇到一些问题,欢迎一起讨论.所以下面重点详细讲解我们常用的Get和Post请求( 以.net core2.2的Http[Verb]为方向 ,推荐该 ...
- ASP.NET Core API 接收参数去掉烦人的 [FromBody]
在测试ASP.NET Core API 项目的时候,发现后台接口参数为类型对象,对于PostMan和Ajax的Post方法传Json数据都获取不到相应的值,后来在类型参数前面加了一个[FromBody ...
- telerik reporting报表
Telerik Reporting是一个非常人性化的控件,一个报表的生成几乎不用写代码,都是通过"所见即所得"模式完成.由于客户需要在实际的项目中运用Telerik Reporti ...
随机推荐
- 基本shell脚本
#!/bin/bash attr=() num= while true do read -p ">>input:" name attr[$num]=$name echo ...
- netty的调优-及-献上写过注释的源码工程
Netty能干什么? Http服务器 使用Netty可以编写一个 Http服务器, 就像tomcat那样,能接受用户发送的http请求, , 只不过没有实现Servelt规范, 但是它也能解析携带的参 ...
- python推导式pythonic必备【华为云技术分享】
版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/devcloud/article/detai ...
- 云享专家倪升武:微服务架构盛行的时代,你需要了解点 Spring Boot
[摘要] 微服务架构的本质在于分布式.去中心化. 随着互联网的高速发展,庞大的用户群体和快速的需求变化已经成为了传统架构的痛点. 在这种情况下,如何从系统架构的角度出发,构建出灵活.易扩展的系统来快速 ...
- Ubuntu 18.04.3 LTS Virtualbox提示“Kernel driver not installed (rc=-1908)”问题修复一例
前两天Ubuntu升级了,重启后启动virtualbox保存 从错误报告上反映出来的问题原因是因为某些内核驱动程序没有经过编译,所以Virtualbox无法正常运行.事实上,在Ubuntu上处理这个问 ...
- 简单易懂的ftp脚本自动登录教程
我在上上篇<nmon脚本--对Linux服务器的监控>的脚本中,使用了ftp的自动登录.结果有人询问,遂决定专门写一篇简单易懂的博客,来说明如何解决ftp的自动登录问题. 一.Window ...
- jQuery操作页面的元素
主要有添加,替换,删除,清空三种方式: 添加又分为,在之前添加,在之后添加,在元素外之前添加,在元素外之后添加.每个添加方式又有俩种方法(效果一模一样): 俩种方法区添加,在原内容之后: p.appe ...
- GZIP怎么运用在.NET MVC 简单实现
ZIP压缩其实就是将网页内容压缩,减少HTML代码网络传输的代价,来提高Web性能. 这个请求的过程解释一下: 1:客户端Request请求.Http_header中会根据相应的浏览器发送相应的编码规 ...
- 曹工说Spring Boot源码(2)-- Bean Definition到底是什么,咱们对着接口,逐个方法讲解
写在前面的话 相关背景及资源: 曹工说Spring Boot源码系列开讲了(1)-- Bean Definition到底是什么,附spring思维导图分享 工程代码地址 思维导图地址 工程结构图: 正 ...
- kratos微服务框架学习笔记一(kratos-demo)
目录 kratos微服务框架学习笔记一(kratos-demo) kratos本体 demo kratos微服务框架学习笔记一(kratos-demo) 今年大部分时间飘过去了,没怎么更博和githu ...