PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.31
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.31
5.5.84 5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 5.5.42 All 160 releases
wp-data-access / WPDataAccess / Utilities / WPDA_Export_Excel.php

WPDA_Export_Excel.php in WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards 5.5.31, at WPDataAccess/Utilities/WPDA_Export_Excel.php

81 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Suppress "error - 0 - No summary was found for this file" on phpdoc generation
5 *
6 * @package WPDataAccess\Utilities
7 */
8
9 namespace WPDataAccess\Utilities {
10
11 use WPDataAccess\WPDA;
12
13 /**
14 * Class WPDA_Export_Excel
15 *
16 * @author Peter Schulz
17 * @since 2.0.13
18 */
19 class WPDA_Export_Excel extends WPDA_Export_Formatted {
20
21 /**
22 * File header for Excel export
23 *
24 * @since 2.0.13
25 */
26 protected function header() {
27 WPDA::sent_header( 'application/vnd.ms-excel; charset=utf-8', null, "{$this->table_names}.xml" );
28
29 echo "<?xml version='1.0' ?>";
30 echo '<?mso-application progid="Excel.Sheet"?>';
31 echo '<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"';
32 echo ' xmlns:o="urn:schemas-microsoft-com:office:office"';
33 echo ' xmlns:x="urn:schemas-microsoft-com:office:excel"';
34 echo ' xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"';
35 echo ' xmlns:html="http://www.w3.org/TR/REC-html40">';
36 echo '<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">';
37 echo '<Author>Exported by WP Data Access</Author>';
38 echo '</DocumentProperties>';
39 echo '<Styles><Style ss:ID="s62"><Font ss:Bold="1"/></Style></Styles>';
40 echo '<Worksheet ss:Name="Table ' . esc_attr( $this->table_names ) . ' export">';
41 echo '<Table>';
42 if ( is_array( $this->rows ) && count( $this->rows ) > 0 ) {//phpcs:ignore - 8.1 proof
43 echo '<Row>';
44 foreach ( $this->rows[0] as $column_name => $column_value ) {
45 echo '<Cell ss:StyleID="s62"><Data ss:Type="String">' . esc_attr( $this->wpda_list_columns->get_column_label( $column_name ) ) . '</Data></Cell>';
46 }
47 echo '</Row>';
48 }
49 }
50
51 /**
52 * Process one row to be export in Excel format
53 *
54 * @param array $row
55 *
56 * @since 2.0.13
57 */
58 protected function row( $row ) {
59 echo '<Row>';
60 foreach ( $row as $column_name => $column_value ) {
61 echo '<Cell><Data ss:Type="String">' . esc_html( $column_value ) . '</Data></Cell>';
62 }
63 echo '</Row>';
64 }
65
66 /**
67 * File footer for Excel export
68 *
69 * @since 2.0.13
70 */
71 protected function footer() {
72 echo '</Table>';
73 echo '</Worksheet>';
74 echo '</Workbook>';
75
76 }
77
78 }
79
80 }
81