Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Ausgabe eines Datensatzes in PHP mit PEAR

Empfohlene Antworten

Veröffentlicht

Hiho ;)

ich würde gerne bei PHP ein von mysql erstelltes Array als Exceldokument ausgeben lassen, dabei scheint PEAR wohl die beste Wahl zu sein. Allerdings check ich den gesamten Aufbau von dem Ding nicht, hat da evtl. jemand nen Tutorial zu oder Ahnung wie das Teil funktioniert, um ganze Arrays schön auszugeben in Excel?

Find immo nicht mal die Möglichkeit, wie ich z.b. die Seitenausrichtung auf Querformat umstelle. Die Doku is zwar umfassend, aber irgendwie hilft sie mir nicht weiter :/

Ok, ich machs nun anders, nämlich:


include('db_data.php');
$sql1 = "SELECT * FROM data order by nname";

$result = mysql_query($sql1, $conn);

$fields = mysql_num_fields($result);

for ($i = 0; $i < $fields; $i++) {
$header .= mysql_field_name($result, $i) . "\t";
}
while($row = mysql_fetch_row($result)) {
$line = '';
foreach($row as $value) {
if ((!isset($value)) OR ($value == "")) {
$value = "\t";
} else {
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
}
$data = str_replace("\r","",$data);
if ($data == "") {
$data = "\n(0) Records Found!\n";
}
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=list.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";



?>
[/php]

Dennoch muss ich hier die Seitenausrichtung vom Sheet manuell (bzw. per Makro) im Excel ändern. Jemand ne Idee wie ich das bereits im PHP Script einbauen kann?

  • 8 Monate später...

hi,

wen es noch interessiert, mit PEAR:

um ein worksheet im querformat zu erhalten benutzt man "$worksheet->setLandscape();"

um ein worksheet im hochformat zu erhalten benutzt man "$worksheet->setPortrait();"

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.