noober Posted January 21, 2009 Share Posted January 21, 2009 Hi guys and gals. I am somewhat a beginner php programmer and I'm having trouble figuring out how to accomplish a task. What I am looking to do is take contents from an xml file and possibly compare it against specific contents from an excel file. The xml file would contain a product and a price which I want to verify. I already have achieved parsing and printing specific content from xml with SimpleXML. So, my question would be, how, if it is at all possible, would one take the info from the one file, then compare it to the excel file (or possibly a file which someone could put their inventory names and prices in...it doesn't necessarily have to be an excel file). Thanks. ...I'm using php5 Link to comment https://forums.phpfreaks.com/topic/141744-solved-compare-xml-against-excel-file-simplexml/ Share on other sites More sharing options...
Mark Baker Posted January 21, 2009 Share Posted January 21, 2009 So, my question would be, how, if it is at all possible, would one take the info from the one file, then compare it to the excel fileTo start with, you need to be able to read data from that second file. If it's an Excel file, you'll need to use a library such as PHPExcel Link to comment https://forums.phpfreaks.com/topic/141744-solved-compare-xml-against-excel-file-simplexml/#findComment-742022 Share on other sites More sharing options...
noober Posted January 21, 2009 Author Share Posted January 21, 2009 It looks like a beautiful solution/start to my problem. I obviously have a few questions/problems though. The only thing is I'm trying to get started with PHPExcel by testing out the example they've given (it would be really nice if the developers would give more than that example for beginning programmers, though I'm not sure if it is necessary because of it's simplicity) but nevertheless I'm coming up with an error, then a series of errors that probably relates to the first one. I have the "Classes" folder in the main directory of the site. I believe I have the right path in the php file...but the error begs to differ. Any ideas? I feel like such a turd for not even being able to get the right path in there... ini_set('include_path', ini_get('include_path').'../Classes'); Warning: include(PHPExcel.php) [function.include]: failed to open stream: No such file or directory in ........ Warning: include() [function.include]: Failed opening 'PHPExcel.php' for inclusion (include_path='.:/usr/lib/php5/Classes') in ......... This is the whole php file. Maybe I'm doing something wrong in here? <?php /** Error reporting */ error_reporting(E_ALL); ini_set('display_errors', 1); /** Include path **/ ini_set('include_path', ini_get('include_path').'../Classes'); /** PHPExcel */ include 'PHPExcel.php'; /** PHPExcel_Writer_Excel2007 */ include 'PHPExcel/Writer/Excel2007.php'; // Create new PHPExcel object echo date('H:i:s') . " Create new PHPExcel object\n"; $objPHPExcel = new PHPExcel(); // Set properties echo date('H:i:s') . " Set properties\n"; $objPHPExcel->getProperties()->setCreator("Maarten Balliauw"); $objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw"); $objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document"); $objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document"); $objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes."); // Add some data echo date('H:i:s') . " Add some data\n"; $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet()->SetCellValue('A1', 'Hello'); $objPHPExcel->getActiveSheet()->SetCellValue('B2', 'world!'); $objPHPExcel->getActiveSheet()->SetCellValue('C1', 'Hello'); $objPHPExcel->getActiveSheet()->SetCellValue('D2', 'world!'); // Rename sheet echo date('H:i:s') . " Rename sheet\n"; $objPHPExcel->getActiveSheet()->setTitle('Simple'); // Save Excel 2007 file echo date('H:i:s') . " Write to Excel2007 format\n"; $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel); $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); // Echo done echo date('H:i:s') . " Done writing file.\r\n"; ?> Also, I'm having trouble figure out if my 1and1 server has php_zip enabled, and if it isn't, how or do I? I assume I can add a line in the php.ini file? Link to comment https://forums.phpfreaks.com/topic/141744-solved-compare-xml-against-excel-file-simplexml/#findComment-742717 Share on other sites More sharing options...
Mark Baker Posted January 21, 2009 Share Posted January 21, 2009 There's currently 28 examples in the /Tests folder of the distribution, demonstrating different features of the library. One of the reader examples should provide you with a starting point. The path '../Classes' is relative to the folder where your script is executing. If your running the 01simple.php in the /Tests folder, and PHPExcel.php is in the /Classes folder, then this should be correct. If you've moved the 01simple.php script to your root folder, the you'd append './Classes' to the include path. A simple phpinfo() script should allow you to see if php_zip is enabled. If you're on a Windows server, then simply uncommenting the appropriate line in php.ini should enable it; but watch out for the corrupted php_zip.dll referenced in http://www.codeplex.com/PHPExcel/Thread/View.aspx?ThreadId=42854. Link to comment https://forums.phpfreaks.com/topic/141744-solved-compare-xml-against-excel-file-simplexml/#findComment-742772 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.