以下是我将xls转换为csv的脚本。无论前面提到的for循环代码片段是什么,它都会先运行。请让我知道如何显示来自以下脚本的图像,然后运行循环脚本:循环执行前的显示图像
<body>
asdjasldjasdlj // Even this text gets load after execution of for loop
<!-- Progress information -->
<div id="information" style="width"><img src="images/L.gif" /></div>
<?php
require_once 'lib/excel_reader2.php';
$excel = new Spreadsheet_Excel_Reader();
$excel->setOutputEncoding('UTF-16');
$excel->read('Student2.xls');
$x=1;
$sep = ",";
$nbSheets = count($excel->sheets);
echo $x." - ".$nbSheets;
$total = $nbSheets;
for($i = 0; $i < $nbSheets; $i++) {
ob_start();
while($x<=$excel->sheets[$i]['numRows']) {
$y=1;
$row="";
while($y<=$excel->sheets[$i]['numCols']) {
$cell = isset($excel->sheets[$i]['cells'][$x][$y]) ? $excel->sheets[$i]['cells'][$x][$y] : '';
$row.=($row=="")?"\"".$cell."\"":"".$sep."\"".$cell."\"";
$y++;
}
echo $row."\n";
$x++;
}
$x = 1; $y = 1;
$fp = fopen("data.csv",'a');
fwrite($fp,ob_get_contents());
fclose($fp);
ob_end_clean();
}
echo "CSV file created successfully";
// Tell user that the process is completed
echo '<script language="javascript">document.getElementById("information").innerHTML="Process completed"</script>';
?>
</body>
http://en.wikipedia.org/wiki/Ajax_%28programming%29 –
什么是上下文从客户端将使用这个脚本? –
@JustinGingyMcDonald它将在loacalhost上运行。脚本工作正常,我只是想显示'加载数据'的图像,直到循环完成工作。 –