ExportExcel.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. namespace PhpMyAdmin\Plugins\Export;
  10. use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
  11. use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
  12. use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
  13. use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
  14. use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem;
  15. use PhpMyAdmin\Properties\Options\Items\SelectPropertyItem;
  16. use PhpMyAdmin\Properties\Options\Items\TextPropertyItem;
  17. /**
  18. * Handles the export for the CSV-Excel format
  19. *
  20. * @package PhpMyAdmin-Export
  21. * @subpackage CSV-Excel
  22. */
  23. class ExportExcel extends ExportCsv
  24. {
  25. /**
  26. * Sets the export CSV for Excel properties
  27. *
  28. * @return void
  29. */
  30. protected function setProperties()
  31. {
  32. $exportPluginProperties = new ExportPluginProperties();
  33. $exportPluginProperties->setText('CSV for MS Excel');
  34. $exportPluginProperties->setExtension('csv');
  35. $exportPluginProperties->setMimeType('text/comma-separated-values');
  36. $exportPluginProperties->setOptionsText(__('Options'));
  37. // create the root group that will be the options field for
  38. // $exportPluginProperties
  39. // this will be shown as "Format specific options"
  40. $exportSpecificOptions = new OptionsPropertyRootGroup(
  41. "Format Specific Options"
  42. );
  43. // general options main group
  44. $generalOptions = new OptionsPropertyMainGroup("general_opts");
  45. // create primary items and add them to the group
  46. $leaf = new TextPropertyItem(
  47. 'null',
  48. __('Replace NULL with:')
  49. );
  50. $generalOptions->addProperty($leaf);
  51. $leaf = new BoolPropertyItem(
  52. 'removeCRLF',
  53. __('Remove carriage return/line feed characters within columns')
  54. );
  55. $generalOptions->addProperty($leaf);
  56. $leaf = new BoolPropertyItem(
  57. 'columns',
  58. __('Put columns names in the first row')
  59. );
  60. $generalOptions->addProperty($leaf);
  61. $leaf = new SelectPropertyItem(
  62. 'edition',
  63. __('Excel edition:')
  64. );
  65. $leaf->setValues(
  66. array(
  67. 'win' => 'Windows',
  68. 'mac_excel2003' => 'Excel 2003 / Macintosh',
  69. 'mac_excel2008' => 'Excel 2008 / Macintosh',
  70. )
  71. );
  72. $generalOptions->addProperty($leaf);
  73. $leaf = new HiddenPropertyItem(
  74. 'structure_or_data'
  75. );
  76. $generalOptions->addProperty($leaf);
  77. // add the main group to the root group
  78. $exportSpecificOptions->addProperty($generalOptions);
  79. // set the options for the export plugin property item
  80. $exportPluginProperties->setOptions($exportSpecificOptions);
  81. $this->properties = $exportPluginProperties;
  82. }
  83. }