1) I have faced some problems when using PHP to create MS Excel files and adding data to the file.
It will give me an error "Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft Office Excel<br/><b>Description:</b> Cannot access read-only document '_eqx-2006-03-03.xls'.' in C:\Attendance\createFile.php:66 Stack trace: #0 C:\Attendance\createFile.php(66): variant->SaveAs('C:\Attendance_...') #1 {main} thrown in C:\Attendance\createFile.php on line 66"
Below is a copy of my code.
//create a new excel file
$xls = new COM("Excel.sheet") or die("Did not connect");
$title = $POST['Title'];
$date = $POST['DateStart'];
$workbook = "C:\Attendance_" . $title . "-" . $date . ".xls";
$wkb = fopen($workbook,'w+') or die("Failed to Open Workbook");
$sheet = "_" . $title . "-" . $date;
echo $sheet;
$sheets = $xls->application->Workbooks->Open($workbook)->Worksheets($sheet);
$sheets->activate;
$cell = $sheets->Cells(2,2);
$cell->activate;
$cell->value = 15000;
$xls->Application->ActiveWorkbook->SaveAs("C:\Attendance_" . $title . "-" . $date . ".xls");
fclose($wkb);
I don't know what is wrong with my code. How to make it not a "read-only document "?
2) I have some output from a barcode reader which will display in the textbox on my broswer. What can i compare the output line by line with my data inside my Excel file?
For example,
I got 10 names displayed in the text box, and I want to compare the name 1 by 1 with the data in my EXcel file and marked as "present" in the same row as the name.
Hope i have explained clearly. I am new to PHP, hope anyone can help me with this.
Thank you.