ExportExcel.class.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Class for exporting CSV dumps of tables for excel
  5. *
  6. * @package PhpMyAdmin-Export
  7. * @subpackage CSV-Excel
  8. */
  9. if (! defined('PHPMYADMIN')) {
  10. exit;
  11. }
  12. /* Extend the export CSV class */
  13. require_once 'libraries/plugins/export/ExportCsv.class.php';
  14. /**
  15. * Handles the export for the CSV-Excel format
  16. *
  17. * @package PhpMyAdmin-Export
  18. * @subpackage CSV-Excel
  19. */
  20. class ExportExcel extends ExportCsv
  21. {
  22. /**
  23. * Sets the export CSV for Excel properties
  24. *
  25. * @return void
  26. */
  27. protected function setProperties()
  28. {
  29. $props = 'libraries/properties/';
  30. include_once "$props/plugins/ExportPluginProperties.class.php";
  31. include_once "$props/options/groups/OptionsPropertyRootGroup.class.php";
  32. include_once "$props/options/groups/OptionsPropertyMainGroup.class.php";
  33. include_once "$props/options/items/TextPropertyItem.class.php";
  34. include_once "$props/options/items/BoolPropertyItem.class.php";
  35. include_once "$props/options/items/SelectPropertyItem.class.php";
  36. include_once "$props/options/items/HiddenPropertyItem.class.php";
  37. $exportPluginProperties = new ExportPluginProperties();
  38. $exportPluginProperties->setText('CSV for MS Excel');
  39. $exportPluginProperties->setExtension('csv');
  40. $exportPluginProperties->setMimeType('text/comma-separated-values');
  41. $exportPluginProperties->setOptionsText(__('Options'));
  42. // create the root group that will be the options field for
  43. // $exportPluginProperties
  44. // this will be shown as "Format specific options"
  45. $exportSpecificOptions = new OptionsPropertyRootGroup();
  46. $exportSpecificOptions->setName("Format Specific Options");
  47. // general options main group
  48. $generalOptions = new OptionsPropertyMainGroup();
  49. $generalOptions->setName("general_opts");
  50. // create primary items and add them to the group
  51. $leaf = new TextPropertyItem();
  52. $leaf->setName('null');
  53. $leaf->setText(__('Replace NULL with:'));
  54. $generalOptions->addProperty($leaf);
  55. $leaf = new BoolPropertyItem();
  56. $leaf->setName('removeCRLF');
  57. $leaf->setText(
  58. __('Remove carriage return/line feed characters within columns')
  59. );
  60. $generalOptions->addProperty($leaf);
  61. $leaf = new BoolPropertyItem();
  62. $leaf->setName('columns');
  63. $leaf->setText(__('Put columns names in the first row'));
  64. $generalOptions->addProperty($leaf);
  65. $leaf = new SelectPropertyItem();
  66. $leaf->setName('edition');
  67. $leaf->setValues(
  68. array(
  69. 'win' => 'Windows',
  70. 'mac_excel2003' => 'Excel 2003 / Macintosh',
  71. 'mac_excel2008' => 'Excel 2008 / Macintosh'
  72. )
  73. );
  74. $leaf->setText(__('Excel edition:'));
  75. $generalOptions->addProperty($leaf);
  76. $leaf = new HiddenPropertyItem();
  77. $leaf->setName('structure_or_data');
  78. $generalOptions->addProperty($leaf);
  79. // add the main group to the root group
  80. $exportSpecificOptions->addProperty($generalOptions);
  81. // set the options for the export plugin property item
  82. $exportPluginProperties->setOptions($exportSpecificOptions);
  83. $this->properties = $exportPluginProperties;
  84. }
  85. /**
  86. * This method is called when any PluginManager to which the observer
  87. * is attached calls PluginManager::notify()
  88. *
  89. * @param SplSubject $subject The PluginManager notifying the observer
  90. * of an update.
  91. *
  92. * @return void
  93. */
  94. public function update (SplSubject $subject)
  95. {
  96. }
  97. }
  98. ?>