ExportExcel.php 2.8 KB

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