工具要求: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. linux进程间通信之共享内存学习记录

    进程 狭义定义:进程是正在运行的程序的实例(an instance of a computer program that is being executed). 广义定义:进程是一个具有一定独立功能的 ...

  2. Cannot read property 'nodeType' of null; audio元素默认样式下载按钮

    1.chrome-->console抛出如下错误: Uncaught TypeError: Cannot read property 'nodeType' of null 错误原因:从stack ...

  3. Go语言学习之路

    我关于Go语言的博客原本发布于我的个人网站:wwww.liwenzhouu.com.但是被某些人抄怕了,没办法只好搬运到博客园. 我的Go语言学习之路 2015年底我因为工作原因接触到了Go语言,那时 ...

  4. 2018 牛客国庆集训派对Day4 - H 树链博弈

    链接:https://ac.nowcoder.com/acm/contest/204/H来源:牛客网 题目描述 给定一棵 n 个点的树,其中 1 号结点是根,每个结点要么是黑色要么是白色 现在小 Bo ...

  5. 从零开始openGL——三、模型加载及鼠标交互实现

    前言 在上篇文章中,介绍了基本图形的绘制.这篇博客中将介绍模型的加载.绘制以及鼠标交互的实现. 模型加载 模型存储 要实现模型的读取.绘制,我们首先需要知道模型是如何存储在文件中的. 通常模型是由网格 ...

  6. ARTS-S docker安装miniconda

    FROM centos:centos7.3.1611 MAINTAINER zhouyang3 <aaa@qq.com> WORKDIR /usr/local ADD ./ /usr/lo ...

  7. Day 04 作业

    目录 作业 简述Python的五大数据类型的作用.定义方式.使用方法: 数字类型 字符串类型 列表 字典 布尔型 一行代码实现下述代码实现的功能: 写出两种交换x.y值的方式: 一行代码取出nick的 ...

  8. jenkins+gitlab+webhook实现自动发布

    实验环境   Jenkins:192.168.1.15 Gitlab:192.168.1.14   一.Jenkins配置   1:安装gitlab hook plugin插件 2:新建一个job 3 ...

  9. 3年Java开发都知道的Redis数据结构和通用命令

    Redis的数据结构 Redis支持多种不同的数据结构,包括5种基础数据结构和几种比较复杂的数据,这些数据结构可以满足不同的应用场景. 五种基础数据结构 String:字符串,是构建其他数据结构的基础 ...

  10. TOMCAT启动报错:org.apache.tomcat.jni.Error: 730055

    TOMCAT启动报错:org.apache.tomcat.jni.Error: 730055 具体原因:不清楚 解决方式:重启应用服务器后,再启动tomcat就可以了 欢迎关注公众号,学习kettle ...