工具要求: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 使用的更多相关文章

  1. 修复Telerik reporting 在网页中使用时的样式

    在ASP.NET 网页或ASP MVC中嵌入Telerik Reporting时,报表出来的样式是有问题的,按扭的位置错位了. 在页面中引入以下CSS文件可以将报表样式修复从而回到正常的报表样式. . ...

  2. AspNet Core Api Restful 实现微服务之旅 (一)

    (一)了解微服务(二)搭建VS项目框架  (三)创建AspNet Core Api VS2017 安装包   链接:https://pan.baidu.com/s/1hsjGuJq 密码:ug59 创 ...

  3. 【从零开始搭建自己的.NET Core Api框架】(七)授权认证进阶篇

    系列目录 一.  创建项目并集成swagger 1.1 创建 1.2 完善 二. 搭建项目整体架构 三. 集成轻量级ORM框架——SqlSugar 3.1 搭建环境 3.2 实战篇:利用SqlSuga ...

  4. .net core api +swagger(一个简单的入门demo 使用codefirst+mysql)

    前言: 自从.net core问世之后,就一直想了解.但是由于比较懒惰只是断断续续了解一点.近段时间工作不是太忙碌,所以偷闲写下自己学习过程.慢慢了解.net core 等这些基础方面学会之后再用.n ...

  5. 【从零开始搭建自己的.NET Core Api框架】(一)创建项目并集成swagger:1.1 创建

    系列目录 一.  创建项目并集成swagger 1.1 创建 1.2 完善 二. 搭建项目整体架构 三. 集成轻量级ORM框架——SqlSugar 3.1 搭建环境 3.2 实战篇:利用SqlSuga ...

  6. 【从零开始搭建自己的.NET Core Api框架】(四)实战!带你半个小时实现接口的JWT授权验证

    系列目录 一.  创建项目并集成swagger 1.1 创建 1.2 完善 二. 搭建项目整体架构 三. 集成轻量级ORM框架——SqlSugar 3.1 搭建环境 3.2 实战篇:利用SqlSuga ...

  7. 详解ASP.NET Core API 的Get和Post请求使用方式

    上一篇文章帮助大家解决问题不彻底导致博友使用的时候还是遇到一些问题,欢迎一起讨论.所以下面重点详细讲解我们常用的Get和Post请求( 以.net core2.2的Http[Verb]为方向 ,推荐该 ...

  8. ASP.NET Core API 接收参数去掉烦人的 [FromBody]

    在测试ASP.NET Core API 项目的时候,发现后台接口参数为类型对象,对于PostMan和Ajax的Post方法传Json数据都获取不到相应的值,后来在类型参数前面加了一个[FromBody ...

  9. telerik reporting报表

    Telerik Reporting是一个非常人性化的控件,一个报表的生成几乎不用写代码,都是通过"所见即所得"模式完成.由于客户需要在实际的项目中运用Telerik Reporti ...

随机推荐

  1. Kafka分区分配策略分析——重点:StickyAssignor

    “ 为什么Kafka在RangeAssigor.RoundRobinAssignor的基础上,又新增了PartitionAssignor,它解决了什么问题?” 背景 用过Kafka的同学应该都知道Ka ...

  2. 【并发编程】ThreadLocal的兄弟InheritableThreadLocal

    本博客系列是学习并发编程过程中的记录总结.由于文章比较多,写的时间也比较散,所以我整理了个目录贴(传送门),方便查阅. 并发编程系列博客传送门 引子 public class InheritableT ...

  3. Python开发GUI工具介绍,实战:将图片转化为素描画!【华为云技术分享】

    版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/devcloud/article/detai ...

  4. 微信SDK接入报undefined symbol错误

    按照官方SDK接入 编译后报如下错误 是因为没有link libc++库导致的.

  5. [TimLinux] MySQL 导入sql文件数据慢的问题解决办法

    慢的时候执行的命令: mysql -uusername -p -hip_address -Ddb_name < ./db.sql 快的时候执行的命令: mysql -uusername -p - ...

  6. 【解决】http: server gave HTTP response to HTTPS client

    [问题]上传镜像到私有仓库时报错 $ docker push xxx.xxx.xxx.xxx:5000/java-8 The push refers to repository [xxx.xxx.xx ...

  7. PG数计算

    PG数计算 原地址:http://xiaqunfeng.cc/2017/09/15/too-many-PGs-per-OSD/ ceph告警问题:”too many PGs per OSD” 的解决方 ...

  8. Java并发编程系列-(2) 线程的并发工具类

    2.线程的并发工具类 2.1 Fork-Join JDK 7中引入了fork-join框架,专门来解决计算密集型的任务.可以将一个大任务,拆分成若干个小任务,如下图所示: Fork-Join框架利用了 ...

  9. ARTS-S k8s常用命令

    本地访问minikube的docker eval $(minikube docker-env) 删除statefulset kubectl delete statefulset web --casca ...

  10. Python3 函数基础2

    目录 可变长参数 可变长形参: *args 可变长实参: *容器类 可变长形参: **kwargs 可变长实参: **字典 函数对象 引用 当做容器类型元素 当做参数传给一个函数 当做函数的返回值 函 ...