Statt der Excel-Datei eine .csv erstellen die dann mit Excel später geöffnet werden kann, währe eine möglichkeit!
lg
Flow
Hallo. Ich habe eine Excel Datei die mehrere Platzhalter enthält (z.B. {NAME}). Diese Platzhalte möchte ich nun mit PHP ersetzen.
Mein bisheriger Versuch:
Öffnen, lesen, schreiben funktioniert. Nur der str_replace zerhaut mir die Datei. Sie lässt sich danach nicht mehr öffnen. Wenn ich eine händisch erstellte Datei und die dynamisch generierte öffne, sehe ich in der Quelle signifikante unterschiede.PHP-Code:$data=implode("",file("Mappe1.xls")); // lese die vorlage ein
$data=str_replace("{NAME}","Müller",$data);
// erstelle eine neue Datei in die geschreiben werden soll
// b flag für eine binäre Datei unter Windows
$fp=fopen("new.xls","wb");
fwrite($fp,$data)
fclose($fp);
Originaldatei
Mit PHP erzeugt:Code:Name: {NAME} Vorname: {VORNAME}ÿ
händisch in Excel geändert:Code:Name: Müller Vorname: Hans Peterÿ
Wie man sieht, scheint Excel den Aufbau der Datei zu ändern.Code:Name: Vorname: Müller Hansÿ
Hat einer von euch eine Idee, wie ich dieser Excel Datei zu leibe rücken kann? Nach möglichkeit ohne COM Objekte, da das Tool später mal auf Linux/Novell läuft.
Danke für Eure Zeit![]()
class GetProfileCustomerEntityReceiverInformationReceiverAndProgrammingInforma...{
public function __construct(){ if(!$this) die(' '); } }
http://www.thedailywtf.com/
Statt der Excel-Datei eine .csv erstellen die dann mit Excel später geöffnet werden kann, währe eine möglichkeit!
lg
Flow
Lesser known Programming Languages #13: SLOBOL
... Although many compilers allow you to take a coffee break while they compile, SLOBOL compilers allow you to travel to Bolivia to pick the coffee. Forty-three programmers are known to have died of boredom sitting at their terminals while waiting for a SLOBOL program to compile. Weary SLOBOL programmers often turn to a related (but infinitely faster) language, COCAINE.
Leider enthält die Excel Datei Grafiken und Formularelemente, sowie mehrere Seiten.
class GetProfileCustomerEntityReceiverInformationReceiverAndProgrammingInforma...{
public function __construct(){ if(!$this) die(' '); } }
http://www.thedailywtf.com/
OK, das ist dann natürlich etwas schwieriger!
Ich bin mir aber ehrlich gesagt nicht sicher ob es so einfach ist Excel-Dateien per PHP zu bearbeiten! Ich glaub da gibt es spezielle Klassen dafür! Müsstest Du mal Google befragen!
lg
Flow
Lesser known Programming Languages #13: SLOBOL
... Although many compilers allow you to take a coffee break while they compile, SLOBOL compilers allow you to travel to Bolivia to pick the coffee. Forty-three programmers are known to have died of boredom sitting at their terminals while waiting for a SLOBOL program to compile. Weary SLOBOL programmers often turn to a related (but infinitely faster) language, COCAINE.
Alle Klassen die ich bisher gefunden habe, können nur Excel Dateien erzeugen, aber leider nicht vorhandene bearbeiten![]()
class GetProfileCustomerEntityReceiverInformationReceiverAndProgrammingInforma...{
public function __construct(){ if(!$this) die(' '); } }
http://www.thedailywtf.com/
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)