Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

laravel turn excel into html table

// Load the excel sheet and convert values to an array:
$data = Excel::load('file.xls')->toArray();

// Convert the keys from the first entry to an array (i.e. the headers):
$headers = array_keys($data[0]);

// Then construct a table:
<table>
    <tr>
        @foreach($headers as $h)
            <th>{{$h}}</th>
        @endforeach
    </tr>

    @foreach($data as $d)
        <tr>
            @foreach($d as $v)
                <td>{{$v}}</td>
            @endforeach
        </tr>
    @endforeach
</table>

Keep in mind this has no error checking, you should provide some.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #turn #excel #html #table
ADD COMMENT
Topic
Name
2+6 =