---
title: "Powermail - Export als xls - Problem mit Charset"
url: "https://www.typo3.net/d/91146-powermail-export-als-xls-problem-mit-charset"
source: "typo3.net"
tags: ["Extensions","Frage","Import & Export","Powermail"]
created: "2009-07-08"
last_reply: "2010-09-29"
replies: 5
solved: false
page: 1
pages: 1
lang: "de"
---

# Powermail - Export als xls - Problem mit Charset

Extensions · 5 Antworten · gestartet 2009-07-08

## Eröffnungsbeitrag

**dabjoern** · 2009-07-08 · [Beitrag #1](https://www.typo3.net/d/91146-powermail-export-als-xls-problem-mit-charset/1)

Hallo Leute,

ich habe hier eine Website, bei der das Charset und die Datenbank auf UTF-8 gestellt sind. Meine Redakteure wollen sich powermail Datensätze mit dem dazugehörigen Modul als xls Datei exportieren. In der Exportdatei sind Umlaute vorhanden, die allerdings nicht richtig dargestellt werden. So wird aus Prämie "PrÃ¤mie". Kann mir da jemand helfen?

Edit: Ich habe mir mal die Variable $this->outputEncoding (class.tx_powermail_export.php) ausgeben lassen. Sie zeigt utf-8 an. Warum stimmt der Header trotzdem nicht?

Edit2: Im HTML Export stimmen die Chars allerdings. Im xls und csv nicht... Sehr komisch.

Viele Grüße, dabjoern

## Antworten

### [#2](https://www.typo3.net/d/91146-powermail-export-als-xls-problem-mit-charset/2) · dabjoern · 2009-07-09

Hallo,

also das Thema ist echt difizil. Ich habe mal die Zeile 266 geändert und dort utf8_decode eingefügt:

```php
if ($key != 'uid') { // static values
if ($export == 'csv') { // CSV only
$table .= '"'.utf8_decode($value).'"'.$this->seperator;
} else { // HTML and EXCEL only
$table .= '<td><b>'.utf8_decode($value).'</b></td>';
}
```

Nun erhalte ich folgendes Ergebnis:
xls: Header und Content passen,
csv: Header passt, Content nicht,
HTML: Header passt nicht, Content passt.

Also habe ich den Code weiter umgestellt:

```php
if ($key != 'uid') { // static values
if ($export == 'csv') { // CSV only
$table .= '"'.utf8_decode($value).'"'.$this->seperator;
} elseif ($export == 'table') { // HTML only
$table .= '<td><b>'.$value.'</b></td>';
} else { // EXCEL only
$table .= '<td><b>'.utf8_decode($value).'</b></td>';
}
```

Jetzt passen die Header. Im csv passt der Content noch nicht. Was machen wir da jetzt?

Viele Grüße, dabjoern

### [#3](https://www.typo3.net/d/91146-powermail-export-als-xls-problem-mit-charset/3) · dabjoern · 2009-07-16

Hat jemand den Fehler auch bemerkt? Was sagt ihr dazu?

Grüße, dabjoern

### [#4](https://www.typo3.net/d/91146-powermail-export-als-xls-problem-mit-charset/4) · comix · 2009-07-17

Bin gerade am genau demselben Problem

Force Charset habe ich auf utf-8 eingestellt und im setup ist das metaCharset auch auf UTF-8 eingestellt.

Wenn ich die CSV exportieren möchte erhalte ich zerschossene Umlaute.

### [#5](https://www.typo3.net/d/91146-powermail-export-als-xls-problem-mit-charset/5) · dabjoern · 2009-08-19

Ich schiebe das mal wieder hoch, vielleicht sieht es Alex Kellner dann...

Grüße, dabjoern

### [#6](https://www.typo3.net/d/91146-powermail-export-als-xls-problem-mit-charset/6) · mferber · 2010-09-29

Ich habe hier das gleiche Problem (Powermail 1.5). Interessanterweise funktioniert der Export über das Frontend einwandfrei, mit cronjob.php (cli) sind die Umlaute in der Exeltabelle "zerschossen".

Für jeden Tipp bin ich dankbar. utf-8 ist - soweit ich das feststellen kann- überall gesetzt.

Gruß
Michael

```php
*  Copyright notice
*
*  (c) 2010 Alex Kellner <alexander.kellner@einpraegsam.net>
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

 
 // Defining circumstances for CLI mode:
define('TYPO3_cliMode', TRUE);
define('PATH_thisScript', $_SERVER['SCRIPT_FILENAME']);
if (!PATH_thisScript) define('PATH_thisScript', $_ENV['_'] ? $_ENV['_'] : $_SERVER['_']);
require(dirname(PATH_thisScript) . '/conf.php');
require(dirname(PATH_thisScript) . '/'.$BACK_PATH.'init.php');
require_once(PATH_t3lib . 'class.t3lib_admin.php');
require_once(PATH_t3lib . 'class.t3lib_cli.php');
require_once(PATH_typo3 . 'template.php');
require_once(PATH_t3lib . 'class.t3lib_htmlmail.php');
require_once('../mod1/class.tx_powermail_export.php'); // include div functions
require_once(t3lib_extMgm::extPath('lang', 'lang.php')); // include lang class
$LANG = t3lib_div::makeInstance('language');
$LANG->init('en');
#$LANG->includeLLFile(dirname(dirname(PATH_thisScript)) . '/mod1/locallang.xml');
$pid = intval($_GET['pid']);
$content = $file = '';

if ($pid > 0) { // if Page id given from GET param
	
	// tsconfig
	$tmp_defaultconfig = array (
		'time' => 86400, // default setting 1 day
		'body' => 'See XLS file in attachment', // default body
		'subject' => 'New powermail export email', // default subject
		'email_receiver' => 'meine@mailadresse', // default: no receiver mail
		'email_receiver_cc' => '', // default: no cc mail
		'email_sender' => 'noreply@einpraegsam.net', // default sender address
		'sender' => 'powermail' // default sender name
	);
	$tmp_tsconfig = t3lib_BEfunc::getModTSconfig($pid, 'tx_powermail_cli'); // get whole tsconfig from backend
	$tsconfig = array_merge((array) $tmp_defaultconfig, (array) $tmp_tsconfig['properties']['exportmail.']); // get tsconfig from powermail cli
	
	if (t3lib_div::validEmail($tsconfig['email_receiver'])) { // if receiver email is set

		// Generate the xls file
		$export = t3lib_div::makeInstance('tx_powermail_export');
		$export->default_start = strftime('%Y-%m-%d %H:%M', (time() - $tsconfig['time'])); // current time minus delta
		$export->default_end = strftime('%Y-%m-%d %H:%M', time()); // current time (like 2010-01-01 00:00)
		$file = t3lib_div::getFileAbsFileName($export->main('email', $pid, $LANG));
		
		if (!empty($file)) { // if file is not empty
			
			// Generate the mail
			$htmlMail = t3lib_div::makeInstance('t3lib_htmlmail'); // New object: TYPO3 mail class
			$htmlMail->start(); // start htmlmail
			$htmlMail->recipient = $tsconfig['email_receiver']; // main receiver
			$htmlMail->recipient_copy = $tsconfig['email_receiver_cc']; // cc
			$htmlMail->subject = $tsconfig['subject']; // mail subject
			$htmlMail->from_email = $tsconfig['email_sender']; // sender email
			$htmlMail->from_name = $tsconfig['sender']; // sender name
			$htmlMail->addAttachment($file); // add attachment
			$htmlMail->addPlain($tsconfig['body']); // add plaintext
			$htmlMail->setHTML($htmlMail->encodeMsg($tsconfig['body'])); // html format if active via constants
			$htmlMail->setHeaders();
			$htmlMail->setContent();
			if ($htmlMail->sendTheMail()) {
				$content .= 'Mail successfully sent';
			} else {
				$content .= 'Powermail Error in sending mail';
			}
	
		} else {
			$content .= 'There are no mails to export in the last ' . $tsconfig['time'] . ' seconds in pid ' . $pid;
		}
	} else {
		$content .= 'Powermail Error: No or invalid receiver Email address (maybe you forget to set the receiver email in the tsconfig of page ' . $pid 

. ')';
	}

} else {
	$content .= 'Powermail Error: No pid given (open this script with pid like ...cronjob.php?pid=1)';
}

echo $content;
?>
```

---

Quelle: „Powermail - Export als xls - Problem mit Charset“, typo3.net, https://www.typo3.net/d/91146-powermail-export-als-xls-problem-mit-charset
Beiträge von Mitgliedern des Forums. Bitte mit Link auf die Diskussion zitieren.
