example.php 991 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. error_reporting(E_ALL ^ E_NOTICE);
  3. require_once 'SpreadsheetExcelReader.php';
  4. $reader = new SpreadsheetExcelReader("example.xls");
  5. // or
  6. $reader = new SpreadsheetExcelReader();
  7. $fileContent = file_get_contents("example.xls");
  8. $reader->readFromBlob($fileContent);
  9. ?>
  10. <html>
  11. <head>
  12. <style>
  13. table.excel {
  14. border-style:ridge;
  15. border-width:1;
  16. border-collapse:collapse;
  17. font-family:sans-serif;
  18. font-size:12px;
  19. }
  20. table.excel thead th, table.excel tbody th {
  21. background:#CCCCCC;
  22. border-style:ridge;
  23. border-width:1;
  24. text-align: center;
  25. vertical-align:bottom;
  26. }
  27. table.excel tbody th {
  28. text-align:center;
  29. width:20px;
  30. }
  31. table.excel tbody td {
  32. vertical-align:bottom;
  33. }
  34. table.excel tbody td {
  35. padding: 0 3px;
  36. border: 1px solid #EEEEEE;
  37. }
  38. </style>
  39. </head>
  40. <body>
  41. <table class="excel">
  42. <?php
  43. $table = $reader->dumpToArray();
  44. foreach ($table as $row) {
  45. echo '<tr>';
  46. foreach ($row as $field) {
  47. echo '<td>' . $field . '</td>';
  48. }
  49. echo '</tr>';
  50. }
  51. ?>
  52. </table>
  53. </body>
  54. </html>