In this post, we will learn create doc file using php laravel. you will learn generate doc file in laravel 7. This article will give you simple example of generate word document from database laravel 6. i explained simply about laravel generate docx. Alright, let’s dive into the steps.
we will generate doc file from html content in laravel 7 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 simple way docs file.
Create Route:
Route::get('generate-docs', function(){
$headers = array(
"Content-type"=>"text/html",
"Content-Disposition"=>"attachment;Filename=myfile.doc"
);
$content = '<html>
<head><meta charset="utf-8"></head>
<body>
<p>My Content</p>
<ul><li>Cat</li><li>Cat</li></ul>
</body>
</html>';
return \Response::make($content,200, $headers);
});
You can try and check it.
I hope it can help you...
Do you like below Tutorials ?
- Angular Json Pipe Example | Json Pipe in Angular 9/8/7
- Angular Slice Pipe Example | Slice Pipe in Angular 9/8/7
- Angular Uppercase Pipe Example | Uppercase Pipe in Angular 9/8/7
- Angular LowerCase Pipe Example | LowerCase Pipe in Angular 9/8/7
- Angular Titlecase Pipe Example | Titlecase Pipe in Angular 9/8/7
- Angular KeyValue Pipe Example | KeyValue Pipe in Angular 9/8/7
- Call Method from One Component to Another Component in Angular
- Angular Push Object into Array Example