GithubHelp home page GithubHelp logo

jimmy-js / laravel-report-generator Goto Github PK

View Code? Open in Web Editor NEW
568.0 18.0 152.0 361 KB

Rapidly Generate Simple Pdf, CSV, & Excel Report Package on Laravel

Home Page: https://packagist.org/packages/jimmyjs/laravel-report-generator

License: MIT License

PHP 32.30% Blade 67.70%
laravel pdf excel report pdf-report excelgenerator csv

laravel-report-generator's People

Contributors

alvaro-canepa avatar bgarrison25 avatar jimmy-js avatar kaptk2 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-report-generator's Issues

Compatibility with Maatwebsite excel 3.0

Hi, I would like to use Maatwebsite Excel 3.0 and report generator but report generator requires 2.1.* and I am not able to use thge package. Will this be compatible with Excel 3.0?

Displaying page #

How can we display page # (running) for report. Please let me know the syntax for the same.

Date Printed on PDF only prints UTC time stamp

I didn't see any way to pass in the timezone to the <script> section of the general-pdf-template blade view. I tried a few things, but was unsuccessful.

In the end, I wound up forking the repo and just removed that line altogether.

Would be nice if we could get a setTimeZone() method on the ReportGenerator class.

Published view not working

I published a the PDF response view and customized it, but when I generate the report, it shows the default view, do I have to change anything after publishing the package?

Hiding the no column breaks the table width

When you cast showNumColumn(false) on your PdfReport, it breaks the table's total width, is there a way to fix this?

Example without No (I'm trying to use the ID of my report to replace it)
image

Example with No
image

Generating a report with Ajax

Can I generate a report with an Ajax request?
I'm using JQuery's ajax method to pass the data to my controller, it gets to the server but the response is odd, is there a way to generate the report in a pop-up window o a blank window?

CSV Report adds number column without header, causing wrong header order

In CSV Report generation, no. column header is not being added but number is added in value, this causes wrong header order. Ex.

my_column_1 my_column_2 my_column_3 my_column_4
auto_added_no my_val_1 my_val_2 my_val_3 my_val_4

Is this expected behavior?

Also we can't use showNumColumn in CSV to prevent this

Eloquent name brings error

I have tried to print the report that has relationships.How can I display a name a name in the relationship. I am using Eloquent in Laravel

Possbile to add ->save() or ->store() on all 3 reports?

I am looking a easier way to store files locally on the server, not downloading or streaming. What I am trying to do is setting a scheduling service, auto creating reports and leaving them on server for user to download, or email them the report.

I know for ExcelReport you can make() then store() the LaravelExcelWriter object,
and for CSV you can set path in Writer::createFromPath then store all data by using insertAll().

Do you think you can create something like store() that can store file on server for all 3 reports PdfReport, ExcelReport and CSVReport?

Undefined variable: showNumColumn

Hey all,

this issue suddenly appeared today, last week all worked fine. Whenever I want to run the PdfReport or ExcelReport, I get the exception "Undefined variable: showNumColumn".

After that, I tried to use PdfReport::showNumColumn(0)->of(...) but that did not help as well... Any idea? I don't need the num column, so any hack to quickly resolve this issue would be appreciated... Seems like the blades for PDF/Excel don't recognize this variable, for whatever reason...

@bgarrison25 Any idea why this is going wrong? Thanks in advance!

How to generate report for parent child relationship

Hello,

I have two tables:

  1. Parent table - Having parentId, parentName, parentGender
  2. Child table - Having childid, parentid, childname, child gender, childbirthdate

I want to generate report something like

Parent Name, Parent Gender
Child Name, Child Date of Birth, Child Gender

Now e.g.
Parent table has 2 records:

  1. Tom, Male
  2. Jerry, Female

Child table has 3 records.

  1. Parent Id - 1, Child Name - Bob, Child Gender - Male, DOB - 20thFeb2016
  2. Parent Id - 1, Child Name - Tos, Child Gender - Female, DOB - 14Jan2014
  3. Parent Id - 2, Child Name - Mary, Child Gender - Female, DOB - 17Sept2017

How to generate such report where single parent can have 2 child rows after that another parent has 1 child row etc.

Please advise.

ERR_INVALID_RESPONSE excel download

hello i have an issue downloading excel when theres alot of rows seleccted , but when theres not a lot of rows selected its download fine .
i got this error on chrome ERR_INVALID_RESPONSE
but when i download it from my local it worked :(
any help ?

Need create a variation to Laravel 5.1

The helper resource_path was added in the project, but it don't exists in laravel 5.1.
I need a branch specific to Laravel 5.1, with de alteration in ServiceProvider.php line 52

from
__DIR__.'/views' => resource_path('views/vendor/laravel-report-generator')

to
__DIR__.'/views' => base_path('resources/views/vendor/laravel-report-generator')

I'm try like this, but i can't get pdf report.

public function report(){
    $title = 'Registered User Report';

    $meta = [
        'Registered on To ',
        'Sort By'
    ];

    $queryBuilder = User::select(['emp_code', 'first_name', 'middle_name', 'last_name']);

    $columns = [
        'EMP Code' => 'emp_code',
        'First Name' => 'first_name',
        'Middle Name' => 'middle_name',
        'Last Name' => 'last_name'
    ];

    return PdfReport::of($title, $meta, $queryBuilder, $columns)
        ->limit(20)
        ->stream();
}

capture

[Feature] Export Report as JSON

Hi, do you know any way to export the report as JSON?

I know I can use the get method on the collection but I would like to have the same parsing / header as the PDF document.

No PDF is Download

I implemented all the readme procedures but while i run the report no file was downloaded with stream().

Trying to make it work but report won't show any fields

Hi, I'm trying to make this work via an addon with PyroCMS. I almost copied the example code word per word, expect for the query where instead of using the model, I used "DB::Table.

The query does hold values from the database but it does not display on the PDF
image

Here's what I''m getting:

image

Here's the code:

public function displayReport(Request $request)
{
$fromDate = '2018-11-23';
$toDate = '2018-11-25';
$sortBy ='name';

    $title = 'Account Balance Report'; // Report title

    $meta = [ // For displaying filters description on header
        'Registered on' => $fromDate . ' To ' . $toDate,
        'Sort By' => $sortBy
    ];

    $queryBuilder = DB::table('testreport_accountinfo_translations')->select('name', 'created_at as registered_at', 'balance')->wherebetween('created_at', [$fromDate, $toDate])->orderBy($sortBy)->get(); 
    dd($queryBuilder);
    $columns = [ // Set Column to be displayed
        'Name' => 'name',
        'Registered At' => 'registered_at',
        'Total Balance' => 'balance',
    ];
    
    // Generate Report with flexibility to manipulate column class even manipulate column value (using Carbon, etc).
    return PDFReport::of($title, $meta, $queryBuilder, $columns)
        ->setpaper('legal')
        ->setorientation('landscape')
        ->editColumn('Registered At', [ // Change column class or manipulate its data for displaying to report
            'displayAs' => function($result) {
                return $result->registered_at->format('d M Y');
            },
            'class' => 'left'
        ])
        ->editColumns(['Total Balance', 'Status'], [ // Mass edit column
            'class' => 'right bold'
        ])
        ->showTotal([ // Used to sum all value on specified column on the last table (except using groupBy method). 'point' is a type for displaying total with a thousand separator
            'Total Balance' => 'point' // if you want to show dollar sign ($) then use 'Total Balance' => '$'
        ])
        ->stream(); // or download('filename here..') to download pdf
}

Report Generator did not install

I got the following error trying to install:
"Your requirements could not be resolved to an installable set of packages"
"Problem 1

  • Conclusion: remove Laravel/Framewokr v5.8.17
  • Conclusion: don't install Laravel/framework v5.8.17"
    Isnt framework the base of laravel?

display none for column?

it is possible without css manipulation in the main template? maybe Edit Column but what I must set? display none didn't help

Facades Not Working

Can you please tell us how to use the Facades?
I always get the Error for Non-static methods should not be called from a static context

maatwebsite/excel 3.0

I have "maatwebsite/excel": "^3.0", so...

composer require jimmyjs/laravel-report-generator

Using version ^1.0 for jimmyjs/laravel-report-generator
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for maatwebsite/excel (locked at 3.0.6, required as ^3.0) -> satisfiable by maatwebsite/excel[3.0.6].
- jimmyjs/laravel-report-generator 1.0.0 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.1 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.10 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.11 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.12 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.13 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.14 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.15 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.16 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.17 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.18 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.2 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.3 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.4 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.5 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.6 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.7 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.8 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- jimmyjs/laravel-report-generator 1.0.9 requires maatwebsite/excel ~2.1.0 -> satisfiable by maatwebsite/excel[2.1.x-dev].
- Conclusion: don't install maatwebsite/excel 2.1.x-dev
- Installation request for jimmyjs/laravel-report-generator ^1.0 -> satisfiable by jimmyjs/laravel-report-generator[1.0.0, 1.0.1, 1.0.10, 1.0.11, 1.0.12, 1.0.13, 1.0.14, 1.0.15, 1.0.16, 1.0.17, 1.0.18, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.0.7, 1.0.8, 1.0.9].

Installation failed, reverting ./composer.json to its original content.

[Feature] Option to hide the title

It would be nice to have an option to hide the title on the excel sheet or pdf.

Currently it is only possible to hide the title by commenting/deleting the respective row in the published views, but if we use simple() method of ExcelReport, the title is still printed.

No support in Laravel Lumen

el archivo "ServiceProvider.php" esta dando problemas al momento de usar la biblioteca en laravel lumen, es posible que le puedas dar soporte para que funcione en dicho framework??

Por el momento pude solucionar el error con el siguiente linea de codigo

public function boot()
{
$this->loadViewsFrom(DIR . '/views', 'report-generator-view');

    if (! $this->isLumen()) {
        $this->publishes([
            __DIR__.'/../config/report-generator.php' => config_path('report-generator.php')
        ], 'laravel-report:config');
    }
    

    $this->publishes([
        __DIR__.'/views' => resource_path('views/vendor/jimmyjs'),
    ], 'laravel-report:view-template');
}

I Added an option to save file to disk, check the code on the description

Hi,
I add the option to export file to disk using the following code, the following example was created on the ExcelReport Class
this also can support custom disk.

public function storeFile($filename,$location=null,$customDisk=null){
$path=$location !=null ? $localtion."/": "";
$export = $this->make();
return Excel::store($export,$path."{$filename}.{$this->format}",$customDisk);
}
i hope you can added it .

PhpExcell

Having this error when intalling the package
Package phpoffice/phpexcel is abandoned, you should avoid using it. Use phpoffice/phpspreadsheet instead.

Call to a member function cursor() on null

Hi. I added this package to my project. But when I run the program, it has this error:
Error
Call to a member function cursor() on null (View: C:\xampp\htdocs\qatest2\vendor\jimmyjs\laravel-report-generator\src\views\general-pdf-template.blade.php)

here's the code to my controller:

`public function filterReport(Request $request)
{
$school = $request->select1;
$accredStatus = $request->accredStatus;

     $title = 'Accreditation Report';
    $meta = [ 
            'School' => $school,
            'Sort By' => $accredStatus
        ];

     $queryBuilder = DB::table('prgrm_accreds')
                    ->join('acad_prgrms', 'acad_prgrms.id', 'prgrm_accreds.acad_prgrm_id')
                    ->join('schools', 'schools.id', 'acad_prgrms.school_id')
                    ->where('schools.school_name', $school)
                    ->where('accred_stats.accred_status', $accredStatus)
                    ->where('current', 'yes')
                    ->get();

     return PdfReport::of($title, $meta, $queryBuilder, $columns)
                ->limit(20) 
                ->stream();

}`

Error: Illegal offset type

Hi

Laravel return this error: Illegal offset type

This is my page:

`...

    $fromDate = $request->input('rm_dt_inicio');
    $toDate   = $request->input('rm_dt_fim');

    // Report title
    $title = 'Relatório de Monitoramento';

    // For displaying filters description on header
    $meta = [
        'Registrados em' => $fromDate . ' To ' . $toDate
    ];

    // Do some querying..
    $queryBuilder = \App\Entidade::get();

    // Set Column to be displayed
    $columns = [
        'Nome' => 'ent_nome',
        'Nome do Display' => 'ent_nome',
        'Data de Cadastro' => 'ent_nome'
    ];

    return PdfReport::of($title, $meta, $queryBuilder, $columns)
        ->editColumn(['Nome', 'Nome do Display', 'Data de Cadastro'], [
            'class' => 'right bold'
        ])
        ->setPaper('a4')
        ->limit(20)
        ->download('teste.pdf');

...`

Title Logo

How to add a logo in the PDF report generator?

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.