Como insertar una imagen a una celda de Excel en PHP
Publicado por Manuel (1 intervención) el 30/05/2018 04:55:05
Hola tengo la siguiente consulta, es cómo puedo agregar una imagen jpg o png a una celda Excel:
Este código es el que estoy utilizando, por fuerza mayor no lo puedo cambiar. a otras opciones.
Este código es el que estoy utilizando, por fuerza mayor no lo puedo cambiar. a otras opciones.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
include_once "eiseXLSX.php";
include_once 'conexion.php';
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT * FROM crts where id=".$_GET['id']." LIMIT 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$filepath = "downloads_xls/".$row['id'].".xlsx";
$xlsx = new eiseXLSX("vacio.xlsx");
//INICIO CODIGO EN CUESTION
$img = '../images/logo_c.jpg'; // Provide path to your logo file
$xlsx->MultiCell(190,40, $xlsx->Image($img, $xlsx->GetX()+40, $xlsx->GetY()+3, 100) ,0,"A");
//FIN CODIGO EN CUESTION
$id = $xlsx->findSheetByName('BORRADOR');
$xlsx->selectSheet($id);
$xlsx->data('A8', $row['field_1']);
$id = $xlsx->findSheetByName('1° ORIGINAL');
$xlsx->selectSheet($id);
$xlsx->data('A8', $row['field_1']);
$id = $xlsx->findSheetByName('2° ORIGINAL');
$xlsx->selectSheet($id);
$xlsx->data('A8', $row['field_1']);
$id = $xlsx->findSheetByName('3° ORIGINAL');
$xlsx->selectSheet($id);
$xlsx->data('A8', $row['field_1']);
$id = $xlsx->findSheetByName('COPIA');
$xlsx->selectSheet($id);
$xlsx->data('A8', $row['field_1']);
$id = $xlsx->findSheetByName('CLIENTE');
$xlsx->selectSheet($id);
$xlsx->data('A8', $row['field_1']);
$xlsx->Output($filepath, "F");
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($filepath).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filepath));
flush(); // Flush system output buffer
readfile($filepath);
}
}
?>
Valora esta pregunta


0