Help in using Spreadsheet_Excel_Writer!
Posted: Fri May 01, 2009 4:35 am
Is it possible to modify a specific sheet of an existing excel file using Spreadsheet_Excel_Writer?
Please provide sample code.
Please provide sample code.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Not going to happen. Post your code first.shishi wrote:Please provide sample code.
Code: Select all
<?
require_once 'Excel/reader.php';
// ExcelFile($filename, $encoding);
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('CP1251');
// Read this file
$data->read('Book1.xls');
// Show data of all the sheets from Book1.xls
for ($h = 0; $h < count($data->sheets); $h++) {
print "<br><table border='1'>";
for ($i = 1; $i <= $data->sheets[$h]['numRows']; $i++) {
print "<tr>";
for ($j = 1; $j <= $data->sheets[$h]['numCols']; $j++) {
print "<td>".$data->sheets[$h]['cells'][$i][$j]."</td>";
}
print "</tr>";
}
print "</table>";
}
// include package for writing
include 'Spreadsheet/Excel/Writer.php';
// DON'T KNOW HOW TO DO IT NEXT
// HERE I NEED TO WRITE SOME DATA INTO A SPECIFIC SHEET IN Book1.xls THEN SAVE IT
?>