GithubHelp home page GithubHelp logo

jumpingyu / xlreport Goto Github PK

View Code? Open in Web Editor NEW

This project forked from image-py/xlreport

0.0 1.0 0.0 16 KB

use dictionary fill excel template and generate report

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

xlreport's Introduction

xlreport

Generate report from a xlsx excel template. Just set some mark in template, xlreport will parse the document, and fill the cell with a dictionary. Supporting Numpy Array as image, and Pandas Dataframe as table.

Personal Information Demo

the template document

    wb = load('Personal Information.xlsx')
    info, keys = parse(wb)
    
    # prepare the data
    img = np.random.randint(0, 255, (100,100), dtype=np.uint8)
    data = {'Name':'YX Dragon',
            'Photo':img,
            'Sex':'Male',
            'Age':'30',
            'Height':170,
            'Weight':75.0,
            'Like_Sport':True}
    
    fill_value(wb, info, data)
    repair(wb) # to repair some bug of openpyxl
    
    wb.save(osp.join(direc, 'person.xlsx'))

then we can got a filled document, here we save it as a pdf document.

Rule of Template

Here is the rule of make a template, please set your page size, suchas A4, A5. Then change the view to page view, then the cell's size could be set in cm.

General Rule

{type Var_Name = Default Value # note},any mark should be in {}, and must have type and var_name, some var must have default value.

Basic Parameter

int,float,str,txt,bool:these vars has the same format, str for a demo,{str Name = YX Dragon # please input your name here}type and name are required, default and note are optional. It seems that default and note are not useful, but if you use xlreport as a ImagePy plugin, default and note would be parsed as some ui element.

Choices Parameter

list:{list Favourite_System = [Windows, Linux, Mac] # please select your favourite system}default value is required, should be a list. If you use code to fill template, choices could be replaced by str. But if you sue xlreport as a ImagePy plugin, choices would be parsed as a combo list.

Image Parameter

img:{img My_Photo = [4.8,4.8,0.9,0] # you photo heredefault value is required, give 4 numbers,[width (in cm),height (in cm),margin (0.9 meas 10% margin),scaled (0 means keep the proportion, 1 means scale to fit the cell's size),note is optional.

Table Parameter

tab:{tab Record = [1,3,0,0] # the result table}default value is required, give 4 numbers, [row step (1 for unmerged cell), column step (1 for unmerged cell), title offset (-1 for the row upon the first data row, 0 means not fill title), index offset (-1 for column left of the first data column, 0 means not fill index)], note is optional.

Use xlreport as ImagePy Plugin

ImagePy is an Image Process Framework written in Python. I write xlreprot as ImagePy's report plugin, we can open image, do filter, analysis, and fill the image and table in template. ImagePy's report will parse the template, and show a parameter dialog, just fill basic information, select the image or table, then generate! You can also try ImagePy.

coins segment and measure

generate report

xlreport's People

Contributors

yxdragon avatar

Watchers

James Cloos avatar

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.