Pregunta:
Fecha: 23-08-2017 06:54:27
(En Español)
mi programa se basa en notas y asistencias, y se puede descargar a través de un documento word pero al presionar descargar de tira el siguiente error:
Fatal error: Cannot use PhpOffice\PhpWord\Shared\String as String because 'String' is a special class name in W:\xampp\htdocs\web1\PhpWord\Element\Text.php on line 20
Este es el codigo
Cualquier ayuda lo agradecería mucho Votos: 0 - Respuestas: 2 - Vistas: 10 Compartir en: Google Facebook Twitter LinkedIn Link
Fatal error: Cannot use PhpOffice\PhpWord\Shared\String as String because 'String' is a special class name[Resuelta]
Hola buenas tarde tengo un error al convertir los datos de una base de datos en un documento word,mi programa se basa en notas y asistencias, y se puede descargar a través de un documento word pero al presionar descargar de tira el siguiente error:
Fatal error: Cannot use PhpOffice\PhpWord\Shared\String as String because 'String' is a special class name in W:\xampp\htdocs\web1\PhpWord\Element\Text.php on line 20
Este es el codigo
<?php
namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Shared\String;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
class Text extends AbstractElement
{
protected $fontStyle;
protected $paragraphStyle;
public function __construct($text = null, $fontStyle = null, $paragraphStyle = null)
{
$this->setText($text);
$paragraphStyle = $this->setParagraphStyle($paragraphStyle);
$this->setFontStyle($fontStyle, $paragraphStyle);
}
public function setFontStyle($style = null, $paragraphStyle = null)
{
if ($style instanceof Font) {
$this->fontStyle = $style;
$this->setParagraphStyle($paragraphStyle);
} elseif (is_array($style)) {
$this->fontStyle = new Font('text', $paragraphStyle);
$this->fontStyle->setStyleByArray($style);
} elseif (null === $style) {
$this->fontStyle = new Font('text', $paragraphStyle);
} else {
$this->fontStyle = $style;
$this->setParagraphStyle($paragraphStyle);
}
return $this->fontStyle;
}
public function getFontStyle()
{
return $this->fontStyle;
}
public function setParagraphStyle($style = null)
{
if (is_array($style)) {
$this->paragraphStyle = new Paragraph;
$this->paragraphStyle->setStyleByArray($style);
} elseif ($style instanceof Paragraph) {
$this->paragraphStyle = $style;
} elseif (null === $style) {
$this->paragraphStyle = new Paragraph;
} else {
$this->paragraphStyle = $style;
}
return $this->paragraphStyle;
}
public function getParagraphStyle()
{
return $this->paragraphStyle;
}
public function setText($text)
{
$this->text = String::toUTF8($text);
return $this;
}
public function getText()
{
return $this->text;
}
}
Cualquier ayuda lo agradecería mucho Votos: 0 - Respuestas: 2 - Vistas: 10 Compartir en: Google Facebook Twitter LinkedIn Link
Respuestas:
-
Fecha: 23-08-2017 07:10:36 Manuel,
Sring es una palabra reservada.
Puedes solucionarlo con un alias así:
use PhpOffice\PhpWord\Shared\String as POString;
y luego donde lo utilices haz el cambio apropiado:
public function setText($text) { $this->text = POString::toUTF8($text); return $this; }Votos: 1 - Link respuesta -
Para participar activamente de la comunidad primero debes autenticarte, ingresa al sistema.Iniciar Sesión
