Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Export2PDF or excel
Author Message
stefendoza Offline
Redoviti posjetitelj
**

Posts: 81
Joined: Apr 2010
Reputation: 1
Post: #1
Export2PDF or excel
Pozdrav ekipi. Hocu da exportujem podatke iz mysql tabele u pdf ili excel, ali imam i slova sa kvakicama. Ja sam malo istrazivao i uspio doci do ovoga sto je uprilogu.


Exportuje on ali mi enkoding nije uspio. Ima li neko prijedlog kako ovo rijesiti? Predpostavlja da bi mi se isto desilo i da exportujem u excel. Jos da napomenem da su mi u bazi polja setovana na utf-8_genereal_ci i da su podaci u bazi valjano upisana tj vide se slova sa kvakicama.


Attached File(s)
.php  export2pdf.php (Size: 1.87 KB / Downloads: 3)
01-08-2012 01:38 PM
Find all posts by this user Quote this message in a reply
Gogy Offline
____
*

Posts: 2,379
Joined: Feb 2006
Post: #2
RE: Export2PDF or excel
Jesi li probao ručno iz PhpMyAdmina exportat u PDF da vidiš kakva je onda situacija?

Pravila foruma | Twitter - Facebook - Google+ |
01-08-2012 10:40 PM
Visit this user's website Find all posts by this user Quote this message in a reply
stefendoza Offline
Redoviti posjetitelj
**

Posts: 81
Joined: Apr 2010
Reputation: 1
Post: #3
RE: Export2PDF or excel
(01-08-2012 10:40 PM)Gogy Wrote:  Jesi li probao ručno iz PhpMyAdmina exportat u PDF da vidiš kakva je onda situacija?

Da jesam, to radi uredno, ali ja moram da napravim skript za taj export - PHPmyadmin moze samo da koristi jedna osoba.
01-08-2012 10:51 PM
Find all posts by this user Quote this message in a reply
r0tring Offline
Redoviti posjetitelj
**

Posts: 237
Joined: Apr 2009
Reputation: 11
Post: #4
RE: Export2PDF or excel
Probaj prvo izvršiti query
Code:
SET NAMES utf8
03-08-2012 09:41 AM
Find all posts by this user Quote this message in a reply
stefendoza Offline
Redoviti posjetitelj
**

Posts: 81
Joined: Apr 2010
Reputation: 1
Post: #5
RE: Export2PDF or excel
(03-08-2012 09:41 AM)r0tring Wrote:  Probaj prvo izvršiti query
Code:
SET NAMES utf8

To sam probao prvo ali nije dalo rezultate. Pisao sam na jos jednom forumu o ovome pa sam dobio neki prijedlog kako bi header trebao da izgleda:

Code:
header('Content-Description: File Transfer');
        header('Content-Type: application/vnd.ms-excel');
        header('Content-Disposition: attachment; filename='.$filename.'.xls');
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
    
        $csv = chr(255) . chr(254) . mb_convert_encoding($csv, 'UTF-16LE', 'UTF-8');
    
        header('Content-Length: '. strlen($csv));
        echo $csv;
        exit;

$filename je ime fajla koji bi se kreirao a promenljiva $csv je string sa podacima a kod mene bi to bio $header i $data (vidi se u prikacenom fajlu).
Navodno ova f-ja mb_convert_encoding() resava problem za sve verzije excel-a. E sad da ja ovo znam upakovati ne bi bio ovde :)
03-08-2012 01:48 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)