Ignore:
Timestamp:
Nov 15, 2018, 10:11:00 PM (6 months ago)
Author:
real3t@…
Message:

Pouvoir exporter les articles à traduire dans un tableau Excel

File:
1 copied

Legend:

Unmodified
Added
Removed
  • _squelettes_/soyezcreateurs_net/trunk/plugins/soyezcreateurs/comptetraduction_export_fonctions.php

    r112416 r112447  
    1 
    21<?php
    32
    4 /***
    5 * This simple utf-8 word count function (it only counts)
    6 * is a bit faster then the one with preg_match_all
    7 * about 10x slower then the built-in str_word_count
    8 *
    9 * If you need the hyphen or other code points as word-characters
    10 * just put them into the [brackets] like [^\p{L}\p{N}\'\-]
    11 * If the pattern contains utf-8, utf8_encode() the pattern,
    12 * as it is expected to be valid utf-8 (using the u modifier).
    13 **/
     3require_once find_in_path('lib/Spout/Autoloader/autoload.php');
     4       
     5use Box\Spout\Writer\WriterFactory;
     6use Box\Spout\Common\Type;
    147
    15 // Jonny 5's simple word splitter
    16 function str_word_count_utf8($str) {
    17   return count(preg_split('~[^\p{L}\p{N}\']+~u',$str));
     8function trad_export_csv($trads) {
     9
     10        $entetes = array(
     11                'ID',
     12                'Nom',
     13                'URL',
     14                'Contenu'
     15        );
     16       
     17        $writer = WriterFactory::create(Type::XLSX); // for XLSX files
     18
     19        $writer->openToBrowser('traduction'); // stream data directly to the browser
     20
     21        $writer->addRow($entetes); // add a row at a time
     22        $writer->addRows($trads); // add multiple rows at a time
     23
     24        $writer->close();
    1825}
    19 ?>
Note: See TracChangeset for help on using the changeset viewer.