Click here to Skip to main content
16,021,115 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
1)how to "print" excel in a page using (excelReader) when there's more than one sheet with showing information in a web browser.Using excel2003.

2)Showing the first row of data from first sheet to the browser , the row of data will be insert into the database after that show the next row in the browser.
Posted
Updated 30-May-11 21:07pm
v4

OK. I had found the solution in "print" multiple excel sheet in a web browser. here are the code ::


<html><br />
    <head><br />
    <style type="text/css"><br />
    table {<br />
    	border-collapse: collapse;<br />
    }        <br />
    td {<br />
    	border: 1px solid black;<br />
    	padding: 0 0.5em;<br />
    }        <br />
    </style><br />
  </head><br />
  <body><br />
		include 'reader.php';<br />
    $excel = new Spreadsheet_Excel_Reader();<br />
	?><br />
	<br />
<br />
Sheet 1:<br /><br /><br />
    <table><br />
    <br />
$excel->read('example.xls');    <br />
$x=1;<br />
while($x<=$excel->sheets[0]['numRows']) {<br />
echo "\t<tr>\n";<br />
$y=1;<br />
while($y<=$excel->sheets[0]['numCols']) {<br />
$cell = isset($excel->sheets[0]['cells'][$x][$y]) ? $excel->sheets[0]['cells'][$x][$y] : '';<br />
echo "\t\t<td>$cell</td>\n";  <br />
$y++;<br />
      }  <br />
echo "\t</tr>\n";<br />
$x++;<br />
    }<br />
    ?>    <br />
</table><br /><br />
	<br />
Sheet 2:<br /><br /><br />
<table><br />
<br />
$excel->read('example.xls');    <br />
$x=1;<br />
while($x<=$excel->sheets[1]['numRows']) {<br />
echo "\t<tr>\n";<br />
$y=1;<br />
while($y<=$excel->sheets[1]['numCols']) {<br />
$cell = isset($excel->sheets[1]['cells'][$x][$y]) ? $excel->sheets[1]['cells'][$x][$y] : '';<br />
echo "\t\t<td>$cell</td>\n";  <br />
$y++;<br />
                                        }  <br />
echo "\t</tr>\n";<br />
$x++;<br />
                                        }<br />
?>    <br />
</table><br /><br />
	<br />
	<br />
<br />
  </body><br />
</html><br />



But now i need is how to display it row by row? Thanks.

For example: the 1st sheet document have 10 row of data. And i want it to display the first row, after reading the data then just showing the next row. thank you.
 
Share this answer
 
Comments
Joan M 31-May-11 2:37am    
You should definitely improve your question and not put a new answer. And when you'll do that, you should clarify a little bit more what you want to achieve... Do you want to show a line in the browser and then (after the line has been made visible to the user) show the next one? or another thing?
jiasing 31-May-11 3:35am    
ok, What i want is show the first row of data , the row of data will be insert into the database after that show the next row in the browser. Thank you.
First of all you should retag your post... I can't see what PHP has to do with printing an Excel file...

This said, you should have searched google... and then you would get results like this one[^].

Take a look there and let's see if it works for you...

Good luck...
 
Share this answer
 
Comments
jiasing 30-May-11 3:02am    
hi, what i need is retrieve the data in an excel file and show it on the web browser. which use the excelReader. And i only can show it when the excel file is only one sheet.
Joan M 30-May-11 3:18am    
Then, what you should do first is to explain your problem a little bit better; and doing it where you've done it won't help a lot as other members will only see it if they bother to read my post. Click on improve question and make it easy for the other members to understand how to "print" excel in a page using (third party product) when there's more than one sheet has something to do with showing information in a web browser.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900