Guten Tag,
ich habe lange kein php mehr programmiert und damals auch nicht wirklich intensiv. Ich habe jetzt ein sehr seltsames Problem.
Ich habe eine Klasse "CSExcelCell" definiert, in dem File "CSExcelWriter.php". Nun versuche ich einfach in meiner "test.php" eine solche Zelle zu instanziieren - get_class behauptet aber felsenfest, das definierte Objekt sei dann ein String. Was mache ich falsch?
Danke schonmal für's Lesen.
Fehlermeldung :
CSExcelWriter.php :
test.php (relevantes Zeilen 18-21 [Anfang der for-Schleife] ) :
/ edit : Ich hatte mal tlw. ein bisschen was hin- und hergeändert und plötzlich ging es. Gefreut und weitergearbeitet, plötzlich ging es wieder nicht mehr - dummerweise weiß ich nicht mehr was ich gemacht habe -.-
ich habe lange kein php mehr programmiert und damals auch nicht wirklich intensiv. Ich habe jetzt ein sehr seltsames Problem.
Ich habe eine Klasse "CSExcelCell" definiert, in dem File "CSExcelWriter.php". Nun versuche ich einfach in meiner "test.php" eine solche Zelle zu instanziieren - get_class behauptet aber felsenfest, das definierte Objekt sei dann ein String. Was mache ich falsch?
Danke schonmal für's Lesen.
Fehlermeldung :
Warning: get_class() expects parameter 1 to be object, string given in test.php on line 21
CSExcelWriter.php :
PHP Code:
class CSExcelCell {
private $cellStyle;
private $cellText;
function CSExcelCell($cellText='',$cellStyle=null) {
$this->cellText = $cellText;
if($cellStyle!=null)
$this->cellStyle = $cellStyle;
}
function setText($text) {
$this->cellText=text;
}
function getText() {
return $this->cellText;
}
function setStyle($style) {
$this->cellStyle=$style;
}
function getStyle() {
return $this->cellStyle;
}
}
test.php (relevantes Zeilen 18-21 [Anfang der for-Schleife] ) :
PHP Code:
include_once('CSExcelWriter.php');
$start=time();
testExcelStuff();
print(time()-$start);
function testExcelStuff() {
//$appDir = str_replace("/test.php","",$_SERVER["SCRIPT_NAME"]);
$dummyFilesPath = $appDir.'xlsdummy';
$finalFilePath = $appDir.'test2.xlsx';
$tempPath = $appDir.'temp2';
$myFile = new CSExcelFile($dummyFilesPath, $finalFilePath, $tempPath);
$style1 = new CSExcelCellStyle('FFCC00','00FF00');
$style2 = new CSExcelCellStyle('AAAAAA','FFFFFF',true);
print(get_class($style2));
for ($i = 0; $i < 200; $i++) {
$row = new CSExcelRow();
$curCell = new CSExcelCell('bla orange grün'.i,style1);
$curCell2 = new CSExcelCell('blubb grau weiß dick'.i,style2);
$curCell3 = new CSExcelCell('hehe nix'.i);
print(get_class(curCell));
$row->addCell(curCell);
$row->addCell(curCell2);
$row->addCell(curCell3);
$myFile->addRow($row);
}
$myFile->save();
}
Comment