DotCreative.Services.OpenReport 2.0.0

Suggested Alternatives

DotCreative.Services.OpenReport 2.0.1

Additional Details

A versão 2.0.0 apresentava erro no momento da geração do arquivo dizendo que não era possível encontrar o diretório.

There is a newer version of this package available.
See the version list below for details.
dotnet add package DotCreative.Services.OpenReport --version 2.0.0
NuGet\Install-Package DotCreative.Services.OpenReport -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotCreative.Services.OpenReport" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotCreative.Services.OpenReport --version 2.0.0
#r "nuget: DotCreative.Services.OpenReport, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DotCreative.Services.OpenReport as a Cake Addin
#addin nuget:?package=DotCreative.Services.OpenReport&version=2.0.0

// Install DotCreative.Services.OpenReport as a Cake Tool
#tool nuget:?package=DotCreative.Services.OpenReport&version=2.0.0

Nuget .NET Standard 2.0

OpenReport

O projeto Open Report nasceu a partir da necessidade de se criar relatórios usando códigos html simples sem a necessidade de utilizar ferramentas complexas como Stimulsoft, ReportViewer e outras mais que, embora extremamente úteis, são complexas demais para objetivos mais simples.

O uso do Open Report é simples. Basta instanciar a classe principal indicando o arquivo html. É possível ainda realizar a interpolação de dados com um objeto. O Open Report utiliza o projeto DotLiquid que faz a interpolação de dados utilizando double mustashe.

Notas dessa versão

Código migrado de .NET 6 para .NET Standard 2.0 para uma maior compatibilidade com aplicações legadas.

Sobre utilização do DotLiquid

(Para interpolação de dados)

Para instruções de uso sobre a biblioteca DotLiquid, acesse http://dotliquidmarkup.org/docs ou https://shopify.github.io/liquid/tags/control-flow/ (Biblioteca base em Ruby - O princípio será o mesmo).

Utilização

// Crie um código HTML para ser utilizado.
string html = @"
<h1>Exemplo de utilização da classe Report</h1>
<p><b>Nome</b> {{ Name }}</p>
<p><b>Telefone</b> {{ Telephone }}</p>
<p><b>Endereço</b> {{ Address }}</p>
<p><b>Sexo</b> {% if (Gender == 'F') %} Feminino {% else %} Masculino {% endif %}</p>
";

// Crie ou instancie um objeto para interpolação
var person = new {
    Name = "Fulano de Tal",
    Telephone = "(xx) xxx-xxx-xxx",
    Address = "Rua X - Bairro Y - Cidade Z",
    Gender = "F"
}

// Instancie um objeto da classe Report. O segundo parâmetro é opcional.
Report report = new(html, person);

É possível gerar o PDF de duas formas:

  • (1) recuperando um array de bytes para ser utilizado como bem entender
  • (2) salvando-o num diretório desejado.

Em ambos os casos, a classe geradora do PDF irá retornar o array de bytes. Veja abaixo as duas implementações:

// recupera o array de bytes
bytes[] content = report.Generate();

/**
 * Salva o PDF no local desejado. O segundo parâmetro deterimina se o arquivo será apagado imediatamente após a
 * geração do PDF. O padrão é `true`.
 */
report.Generate("diretorio/arquivo.pdf", false);
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.2 1,276 10/4/2022
2.0.1 609 7/26/2022
2.0.0 473 7/25/2022
1.0.1 499 7/8/2022
1.0.0 511 7/8/2022

Nesta versão, a estrutura foi modificada de .NET 6 para .NET Standard para uma melhor compatibilidade com aplicações legadas.