format ) { return new CsvWriter( $stream, $request->delimiter ); } return new XlsxWriter( $stream, self::column_types( $request->fields ), wc_get_price_decimals(), __( 'Orders', 'modulary-export' ) ); } /** * Excel cell type per column. A value that doesn't fit its type (e.g. * "Guest" in Customer ID) is still written, as text. * * @param string[] $fields Field keys in column order. * @return array */ public static function column_types( array $fields ): array { return array_map( static function ( string $key ): string { if ( Fields::money( $key ) ) { return XlsxWriter::MONEY; } if ( in_array( $key, self::NUMBERS, true ) ) { return XlsxWriter::NUMBER; } return in_array( $key, self::DATES, true ) ? XlsxWriter::DATE : XlsxWriter::TEXT; }, array_values( $fields ) ); } }