onlinecode

Generate word document file in php Laravel 5 Example

Generate word document file in php Laravel 5 Example

In this post we will give you information about Generate word document file in php Laravel 5 Example. Hear we will give you detail about Generate word document file in php Laravel 5 ExampleAnd how to use it also give you demo for it if it is necessary.

In this example, i will explain how to create docs file using php laravel 5. i will show you simply way to generate docx file in laravel 5.8. you can easily create create word document file in laravel 5. we will generate *.doc file without using any composer package.

we 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 simple way docs file.

Create Route:

Also see:Allow Only Certain ip addresses to API in Laravel 5.8

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…

Hope this code and post will helped you for implement Generate word document file in php Laravel 5 Example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Exit mobile version