The JSON content is as follows:
[{"Ztdid": "100000", "Ztdno": "001", "Ztdname": "Shop 1th", "Address": "XX City, ZZ District, No. No. 01 yy Road Shop", "Remark": "," Areaid ":" "," Ztdtel ": "0000-8888888", "ztdcontact": "Zhang San"},{"Ztdid": "100001", "Ztdno": "002", "Ztdname": "Shop 1th", "Address": "XX City, ZZ District, No. 01 yy Road Shop", " Remark ":", "Areaid": "," "Ztdtel": "0000-8888888", "ztdcontact": "Lie Triple"}]
JSON parses and outputs Excel
Reply to discussion (solution)
Format the array first, and then you can build it with some classes that generate Excel, such as http://code.google.com/p/php-excel/
Phpexcel or some other lightweight plugin to generate Excel
Turn JSON into data first, Json_decode
Then generate Excel and put the input in the array into
Format the array first, and then you can build it with some classes that generate Excel, such as http://code.google.com/p/php-excel/
Header ("content-type:text/html; Charset=utf-8 ");
Require ' php-excel.class.php ';
$json = ' [{"Ztdid": "100000", "Ztdno": "001", "Ztdname": "Shop 1th", "Address": "XX City, ZZ District, No. 01 yy Road", "Remark": "," Areaid ":" 01 "," Ztdtel ":" 0000-8888888 "," ztdcontact ":" Zhang San "},{" Ztdid ":" 100001 "," Ztdno ":" 002 "," Ztdname ":" Shop 1th "," Address ":" XX City zz Zone yy Road No. 01 Shop "," Remark ":", "Areaid": "", "Ztdtel": "0000-8888888", "ztdcontact": "Lie Triple"}] ';
$SR = Json_decode ($json, true);
echo "
";
Var_dump ($SR);
$data = $SR;
$xls = new Excel_xml (' UTF-8 ', false, ' My Test Sheet ');
$xls->addarray ($data);
$xls->generatexml (' my-test ');
?> To the 1 floor, out into a row?
Header ("content-type:text/html; Charset=utf-8 ");
Require ' php-excel.class.php ';
$json = ' [{"Ztdid": "100000", "Ztdno": "001", "Ztdname": "Shop 1th", "Address": "XX City, ZZ District, No. 01 yy Road", "Remark": "," Areaid ":" 01 "," Ztdtel ":" 0000-8888888 "," ztdcontact ":" Zhang San "},{" Ztdid ":" 100001 "," Ztdno ":" 002 "," Ztdname ":" Shop 1th "," Address ":" XX City zz Zone yy Road No. 01 Shop "," Remark ":", "Areaid": "", "Ztdtel": "0000-8888888", "ztdcontact": "Lie Triple"}] ';
$SR = Json_decode ($json, true);
echo "
//var_dump ($SR);
$headeAarray = Array ();
$headeAarray [] = Array (' Store id ', ' Store number ', ' Store name ', ' address ', ' tag ', ' Area ID ', ' Contact phone ', ' contact '); Table header two-dimensional array
$dataArray = Array ();
while ($row = ($SR)) {
$dataArray [] = Array ($row [' Ztdid '], $row [' Ztdno '], $row [' Ztdname '], $row [' Address '], $ro w[' Remark ', $row [' Areaid '], $row [' Ztdtel '], $row [' ztdcontact '];
}
$xls = new Excel_xml (' UTF-8 ', false, ' My Test Sheet ');
$xls->addarray ($headeAarray);
$xls->addarray ($dataArray);
$xls->generatexml (' my-test ');
?>
So not yet, do you have a classmate to guide you?
JSON conversion under format, call Npoi DLL, generate data to be exiled to Excel, download it