gogu
gogu

Reputation: 633

php export to excel not showing gridlines

I have this code

<?php
header("Content-type: application/vnd.ms-excel; name='excel'");

header("Content-Disposition: filename=export.xls");
// Fix for crappy IE bug in download.
header("Pragma: ");
header("Cache-Control: ");
echo $_REQUEST['datatodisplay'];
?>

It puts the data from a html table into excel, but the only problem is that i don`t see the gridline in the sheet. Am i missing something? Thanks

Upvotes: 7

Views: 4050

Answers (3)

Ingus
Ingus

Reputation: 1044

Today i run into same issue as OP did.

I found @Jayant Pandey answer to be really close to my needs! But issue was that grid border was bigger that header border so instead of 1px i used 0.1pt

Example:

<!DOCTYPE html>
<html>
<body style="border: 0.1pt solid #ccc"> 
   <--! SOME EXCEL CONTENT HERE -->
</body>
</html>

I do know this is an old question but maybe someone is looking for this!

Upvotes: 4

Jayant Pandey
Jayant Pandey

Reputation: 110

Just set

 <body style="border: 1px solid #ccc"> 

in your HTML page that will render in excel file.

Upvotes: 2

Aaron McMahon
Aaron McMahon

Reputation: 11

Make sure you DO NOT have a "background-color" attribute defined for your HTML <BODY> tag. That was my problem. Remove it and all the gridlines will magically re-appear in Excel.

Upvotes: 1

Related Questions