Laravel 6 Generate Word File
Feb 11, 2020
Hi Guys,
In this blog, I will explain how to generate a word document file in laravel. we will show the example of create word document file in laravel.you can easy to generate word file in laravel.we will generate *.doc file without using any composer package. I will generate doc file from html content in laravel 5 application.
We might be some time require to create docs file from database in laravel. if you need to same requirement then you can easily achieve to generate word document.We will use headers with Html content and file name will be *.docx. we can use simple html tag like p, strong, ul, li, etc. that all tags will support for creating docs file. you can follow this tutorial to create a simple way docs file.
Here i give you full example of generate word document file example like create route. So you have to just follow example.
Create Route:
Now,we need to create route for generate word document file in laravel.So following add route fille path.
following path:/routes/web.php
<?php
Route::get('generate-docs', function(){
$headers = array(
"Content-type"=>"text/html",
"Content-Disposition"=>"attachment;Filename=myGeneratefile.doc"
);
$content = '<html>
<head><meta charset="utf-8"></head>
<body>
<p>My Blog - Nicesnippets.com</p>
<ul><li>Php</li><li>Laravel</li><li>Html</li></ul>
</body>
</html>';
return \Response::make($content,200, $headers);
});
It will help you...
- How to Notifications With database Driver in Laravel 11?
- How to Send Email Via Notification in Laravel 11?
- How to Install and Configure Laravel 11 Debugbar?
- How to Like Dislike System in Laravel 11?
- How to Paginate a Model with Relationship in Laravel 11?
- Laravel 11 Upload Files to Amazon S3 Example
- Laravel 11 Send WhatsApp Messages Example
- Laravel 11 Rest API Authentication Using JWT Tutorial