Giter Club home page Giter Club logo

maltreport's Introduction

MaltReport

NuGet Stats Build status Build Status

PLEASE NOTE:

  • At this very moment I'm rewriting the old library, the next coming v3.0 will be an incompatible version;
  • I'm also working on a additional commerce library for the docx/xlsx support, closed-source library for MS-Office seems fair;
  • The super old and buggy OfficeML support will be dropped, the OfficeML format is a legacy from 2003;
  • More real world unit tests, more documents;
  • Check dev branch to track the progress of the incoming v3 series.

MaltReport is an OpenDocument/OfficeOpenXML powered document template engine for .NET and Mono, it is inspired by the excellent Relatorio Project.

There is a briefly introduction in Chinese: MaltReport2 中文使用简介

MaltReport DO NOT REQUIRES MS-Office or LibreOffice to generate document. Instead MaltReport manipulates ODT/ODS/XLS/DOC file by itself, so it could be fast & reliable.

Documents

Getting Started

Prerequisites

  • Visual Studio 2017: This project is written in C# 7.0 using Microsoft Visual Studio 2017 Community Edition.

Supported Platform

  • .NET Framework 4.6.1
  • .NET Standard 1.6+

Installation

MaltReport can be installed from NuGet.

Demo & Usage:

Step 1: Organize your data into Context

var employees = new Employee[]
{
    new Employee{ Name = "Micheal Scott", JobTitle = "Branch Manager" },
    new Employee{ Name = "Pam Beesly", JobTitle = "Office Administrator" },
    new Employee{ Name = "Jim Halpert", JobTitle = "Salesman" },
    new Employee{ Name = "Dwight Schrute", JobTitle = "Salesman" },
    new Employee{ Name = "Andy Bernard", JobTitle = "Salesman" },
};

var image = new ImageBlob("jpeg", File.ReadAllBytes("Image.jpeg"));

var data = new Dictionary<string, object>()
{
    { "employees", employees },
    { "image", image },
};

var context = new TemplateContext(data);

Step 2: Prepare your template

Template

Step 3: Load & render your template

using (var stream = File.OpenRead("EmployeesTemplate.odt"))
{
    var odt = OdfDocument.LoadFrom(stream);
    var template = new OdtTemplate(odt);

    var result = template.Render(context);

    var desktopDir = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
    var outputFile = Path.Combine(desktopDir, "generated.odt");

    result.Save(outputFile);
}

Step 4: Check the generated document out:

Generated Document

License

MaltReport is licensed in the MIT license.

Author: Wei "oldrev" Li [email protected]

  • Copyright (C) 2009 Wei "oldrev" Li
  • Copyright (C) 2010-2016 Sandwych Consulting LLC.
  • Copyright (C) 2017-TODAY Binary Stars Technologies LLC. & Contributors

CREDITS

maltreport's People

Contributors

koenvanexem avatar oldrev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

maltreport's Issues

Using liquid syntax inside of tempaltes

Would it be possible to use liquid syntax inside of the template?

For example for rounding numbers or similar things.

(Example showing what I mean, see last column of the table)
image

where is the ImageBlob class?

I see your HollowWorld Project,But I Couldn't Find ImageBlob Class,So I Coudn't Replace Image To DOC Document ! How Can I Resolve This Problem ?

Sandwych.Reporting.OfficeML missing (v2.1.1)

Hi,

Just installed MaltReport2 v2.1.1 in a VS2017 project via NuGet.

When referencing Sandwych.Reporting, OfficeML is missing as shown in your example: WordMLDocumentTest.cs

image

Any ideas?

Thanks

Thread deadlocking

AbstractZipDocument.cs Line 21:
this.OnLoadAsync(inStream).GetAwaiter().GetResult();
may lead to thread deadlock in some cases,

can be changed to
Task.Run(()=> this.OnLoadAsync(inStream)).Wait();

to avoid problem.

Image Render

Hello, I tried to create a document (odt) with an embedded image. In the image, just replace the name with "$var". When you try to replace it with the context, the file is broken. How do I associate the image I want to replace with the context?

Using NuGet Version ( 2.1.1 )

System.IO.MemoryStream ms = new MemoryStream();
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
ms.GetBuffer();
Image im = new Image("png", ms.GetBuffer());

var renderContext = new Dictionary<string, object>()
{
       { "var", im },
}

OdfTemplate a = new OdfTemplate();
a.Load(path);
a.Compile();
IDocument b = a.Render(renderContext);
b.Save(@"C:\temp\simpleImageMap.ods");

Regargs

.Net Standard 1.x Support

The main barrier to prevent to support .Net Standard is the dependency of the NVelocity library.

NVelocity was released in many years before and can not be easily port to .Net Standard 1.x.

So that's the plan: Rewrite VTL(Velocity Template Language) evaluation implementation using a parsing library that support .NET Standard. At this moment the almost reasonable choice seems to be Sprache.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.