doucan1979
doucan1979
2013-03-07 07:57

使用PHP在Excel中使用单元格边框

已采纳

I'm using clean php to draw excel table:

$xls .= "Field\t\Cell1\t\Cell2\tCell3
"
$xls .= chr(hexdec('FF')) . chr(hexdec('FE')) . $xls; //headers
echo $xls;

Is there any way to draw cell borders without using excel-library?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

3条回答

  • duanmao1975 duanmao1975 8年前

    If you really want to output an Excel file with almostly everything possible in Excel, you should use the following easy to use set of PHP classes:

    http://phpexcel.codeplex.com/

    点赞 评论 复制链接分享
  • douzuita7325 douzuita7325 8年前

    No, you can't control formatting in a CSV file.

    Excel accepts a multitude of formats though, so if you don't feel like breaking out phpexcel, you could create a SpreadsheetML file instead. It's a format quite similar to html and you can control a lot of formatting in there.

    点赞 评论 复制链接分享
  • douzhong3038 douzhong3038 8年前

    Excel has the knowledge to work with plain HTML tables. This will generate a warning from excel, but if you continue, it will show a table with border/colors/etc.

    <?
    header('Content-Type: application/vnd.ms-excel');
    ?>
    <table border='1'>
    <tr>
      <td style='background-color:#f00;'>header</td>
      <td style='background-color:#f00;'>header</td>
    </tr>
    </table>
    
    点赞 评论 复制链接分享