Page 1 of 1

Help in using Spreadsheet_Excel_Writer!

Posted: Fri May 01, 2009 4:35 am
by shishi
Is it possible to modify a specific sheet of an existing excel file using Spreadsheet_Excel_Writer?
Please provide sample code.

Re: Help in using Spreadsheet_Excel_Writer!

Posted: Fri May 01, 2009 4:41 am
by Benjamin
shishi wrote:Please provide sample code.
Not going to happen. Post your code first.

Re: Help in using Spreadsheet_Excel_Writer!

Posted: Fri May 01, 2009 4:50 am
by shishi
ok here's what i have so far:

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
 
 
?>