ExportExcel.php 3.0 KB

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