I implemented this library to generate barcodes images in my laravel project https://github.com/milon/barcode
For generating the excel sheet i use this library :
https://github.com/Maatwebsite/Laravel-Excel
For the barcode image i just add a value in my database and then i convert that value in a barcode image and know i need to export the barcode in excel
For exporting the barcode i tried many things but none of them seems to work
in my view i tried different methods for exporting the barcode
The first method :
<td><img src="data:storage/app/upload/;base64,{!! DNS1D::getBarcodePNG("$employee->barcode", 'C39')!!}" ></td>
and gives me the following error:
(1/1) PHPExcel_Exception File
data:storage/app/upload/;base64,iVBORw0KGgoAAAANSUhEUgAAAcAAAAAeAQMAAACBqFzbAAAABlBMVEX///8AAABVwtN
AAAAAXRSTlMAQObYZgAAACpJREFUOI1jOHD
/Jk/B878OcN//gyxGKSHYVTjqMZRjaMaRzWOaqSXRgC0qVOpA6XqWgAAAABJRU5ErkJggg==
not found!
when i use this code :
<td>{!! DNS1D::getBarcodeHTML("$employee->barcode", "C39")!!}</td>
it gives me the following error:
This site can’t be reached
The webpage at
http://127.0.0.1:8000/admin/employees/J80302041D/more/excel might be
temporarily down or it may have moved permanently to a new web
address. ERR_INVALID_RESPONSE
the controller that i use to export the barcode:
public function excel($nr_personal,Request $request)
{
$employees = Employee::where('nr_personal',$nr_personal)->get();
$worker = Employee::where('nr_personal',$nr_personal)->first();
Excel::create('Employee Excel', function($excel) use ($employees, $worker) {
$excel->sheet('Excel sheet', function($sheet) use ( $employees, $worker) {
$sheet->loadView('admin.employees.excel')->with('employees', $employees)
->with('worker', $worker);
$sheet->setOrientation('landscape');
});
})->export('xls');
}
How can i export the barcode in a excel sheet??
Related
I have an excel which is on the server with some important formulae, So I am copying this data to file A (demo excel file) and now trying to add data in file A sheets (Worksheet 1, Worksheet 2)
enter image description here
and then download the file A.
I am using following versions :
Laravel : 8
PHP : 7.2
maatWebsite : 3.1
Also, I have tried by adding the load method of laravel excel but that method is deprecated in this package and in place of that I have to use the import method through which I couldn't edit the file specific to sheet.
`Excel::load('Filename', function($excel) {
$excel->sheet('Sheetname', function($sheet) {
$sheet->fromArray(array(
array('data1', 'data2'),
array('data3', 'data4')
));
});
})->export('xls');`
Thanks in advance
The solution that fits my criteria and I get the answer.
I am working as a freelancer and one of my clients asked me to create designed xls file for a Laravel project.
Using Laravel and Maatawebsite for xls files I have generated a xls file using this code:
Excel::create('extract', function ($excel) use ($data) {
$excel->sheet('mySheet', function ($sheet) use ($data) {
$sheet->fromArray($data);
});
})->download('xls');
This function is generating a xls file like this one:
Generated xls file
It is possible to generate something designed like example from bellow using PHP or Laravel?
How xls file should look like
Of course it is possible, but you'd have to do alot of the styling stuff in your code.
There are a couple of good Excel libraries for PHP available, f.e.
https://github.com/PHPOffice/PhpSpreadsheet
I'm using Laravel Excel to dump a number of records to XLS format.
Each of my records has an image_url field that contains a remote URL to a JPG file.
I'd like to display these images in the final XLS file, in their own column.
I tried creating a Blade template for the export, but when using <img> tags, the images don't appear in the XLS file. I'm not getting any errors, and the documentation for Laravel Excel is very sparse when it comes to image integration.
So what would be the easiest way to get the images to display in the XLS, using Laravel Excel? Is there some way I can get the Blade template to work, or must I add the images more programmatically?
something like this should work, you gotta load the PHPExcel_Worksheet_Drawing library.
$filename = 'File Name';
Excel::create($filename, function($excel) {
$excel->sheet('sheet name', function($sheet) {
$objDrawing = new PHPExcel_Worksheet_Drawing;
$objDrawing->setPath(public_path('your/image/path.jpg')); //your public image path
$objDrawing->setPath(storage_path('your/image/path.jpg')); //your storage image path
$objDrawing->setCoordinates('A2');
$objDrawing->setWorksheet($sheet);
});
})->export('xls');
I am using the below code. but still it's downloading the files instead of viewing.
public function viewFiles(StoreBusinessDevelopment $request, $file, $id)
{
$businessDevelopment = BusinessDevelopment::select('created_by', 'rfp_id')
->where('id', '=', $id)
->get();
$mimeType = File::mimeType(public_path('/uploads/'.$businessDevelopment[0]['created_by'].'/'.$businessDevelopment[0]['rfp_id'].'/'.$file));
return response()->file(public_path('/uploads/'.$businessDevelopment[0]['created_by'].'/'.$businessDevelopment[0]['rfp_id'].'/'.$file),[
'Content-Type' => $mimeType
]);
}
You can just convert files to PDF format and then return it to browser.
Browser unable to read .doc|xls|xlsx files. But you can view / rander it by using some tricks.
Example 1
First upload the file like i say .doc|xls|xlsx and make it as array of data. By using php -> laravel that have a module/repo for excel file read and parse it as array.
After make it as array and print this array as html table and browser must rander it.
For more info :
Laravel Excel
I have an xls file which i was trying to upload using PhpExcel plugin .
My code is like this
Excel::load($file_path, function($sheet) {
$detail = $sheet->get();
var_dump($detail);
});
Since my file had excel formula the Plugin is throwing following error
PHPExcel_Calculation_Exception: 10!I9 -> Formula Error: Unexpected ,
My question is how do i remove the formula and then try uploading it ?
Thanks