Others - Sunday, June 1, 2008 10:33 - 0 Comments
Kopete, The KDE Instant Messenger
Kopete, The KDE Instant Messenger
Kopete is an instant messenger supporting AIM, ICQ, MSN, Yahoo, Jabber, IRC, Gadu-Gadu, Novell GroupWise Messenger, and more. It is designed to be a flexible and extensible multi-protocol system suitable for personal and enterprise use.
The goal of Kopete is to provide users with a single easy-to-use way to access all of their instant messaging systems. The interface puts people first, and is integrated with the system address book to let you access your contacts from other KDE applications. IM can be intrusive, but Kopete’s notification system Continue…
Other Recent Articles
- Warning Signs You Can’t Ignore
Warning Signs You Can’t Ignore
Buying a home? Selecting a surgeon? Trying to tell if she’s true? The FBI’s best profilers are standing by to help you spot, and avoid, big trouble.trained in observation, investigation, and interpretation. By studying the facts of a case, inspecting forensic evidence, and reviewing law-enforcement witness interviews, profilers can often predict […]
- Robotic Jellyfish Swim and Fly at Hannover Fair
Robotic Jellyfish Swim and Fly at Hannover Fair
The biggest draws at Festo’s Hannover Fair exhibits have been biologically inspired robotic creatures that show off cutting-edge automation technologies. Turning once again to nature for inspiration, the - The Real Indiana Jones
The Real Indiana Jones
Born in 1867 and disappeared in 1925 while searching for what he called “The Lost City of Z” with his son, Jack, Col. Percy Fawcett is the inspiration for the character Indiana Jones.
True to form, just like the character he inspired, Fawcett had an equal disdain for snakes. According to The Museum […] - Popular Wealth - Free Photoshop Brushes To Download
Popular Wealth - Free Photoshop Brushes To Download
Free Photoshop Brushes
Getting the most out of your photoshop software requires plugins and tools like the following 300+ Free Photoshop Brushes that have graciously been made available for download by their authors. I - 5 Ways To Combat Aging
5 Ways To Combat Aging
1. Drink a lot of water
The benefits of drinking water cannot be understated. It is used by the body to flush out toxins and other waste products. Water also is one of the best tools for weight loss, besides assisting in clearing your skin.
Drinking a good amount of water could lower […]
Most Popular Content
- Kopete, The KDE Instant Messenger
- Warning Signs You Can’t Ignore
- Robotic Jellyfish Swim and Fly at Hannover Fair
- The Real Indiana Jones
- Popular Wealth - Free Photoshop Brushes To Download
- 5 Ways To Combat Aging
- Inflatable robots could explore Mars
- Thinking the Way Animals Do
- Top 10 things to do in a blackout
- The most natural drug
- 30 Websites to follow if you’re into Web Development
- Please,I want you to help me with some of your books that will enable me to keep...
- You should also mention Ubercart (http://www.ubercart.org) a very powerful Drupa...
- Hello i am interessted on this script please can you contact me!?...
- Excellent article and oh so true.
Thanks...
- Well done.
If you use Ubuntu for, say, half a hour, you'll never go back to W...
- I own a "Super Battery" chinesse mobile phone, Chivak78, and I can assure you th...
- Thank You Very MUCH!!!
I had a working key, but the last time I reinstalled, it...
- Is this big deal end yet ?...
PHP, Tip & Tricks - May 30, 2008 3:20 - 0 Comments
Reuse Excel business logic with PHPExcel
Reuse Excel business logic with PHPExcel
n many companies, business logic resides in Excel. This business logic is sometimes created by business analysts and sometimes by business users who want to automate parts of their everyday job using Excel. This same Excel-based business logic is often copied into an application (i.e. a website) and is maintained on 2 places: if the Excel logic changes, the application should also be modified. Did you know you can use PHPExcel to take advantage of the Excel-based business logic without having to worry about duplicate business logic?
Here’s a scenario: You are working in a company which sells “dream cars”. For every model, the company has created an Excel spreadsheet which is used to calculate the car’s price based on customer preferences. These spreadsheets are updated frequently in order to reflect the car manufacturer’s pricing schemes.
Your manager asks you to create a small website which accepts some input fields (Does the customer want automatic transmission? What colour should the car be painted? Does the customer want leather seats? Does the customer want sports suspension?). Based on these questions, the car’s price should be calculated. Make sure all prices on the website are in sync with this Excel sheet!
Download example source code
View live example
1. Create the Excel sheet containing business logic
First of all, we’ll create an Excel sheet containing business logic. If you’re lazy, download my example here. To make things easy for yourself when scripting, make sure you add some defined names on each field you want to use as input/output. Of course it’s possible to work with the sheet’s cell references later on, but if you want to be able to change the location of cells within the worksheet later, these defined names are much easier!
2. Download the latest PHPExcel version
You can find PHPExcel on www.phpexcel.net. If you want a stable version, download an official release. The source code tab on CodePlex reveals the latest Subversion source code if you want to use it.
3. Create the web based front-end
Next thing we’ll do is creating a simple webpage containing an HTML form which corresponds woth the parameters you want to pass to the Excel sheet.
4. Let’s do some PHP coding!
Since you came here for the good stuff, here it is! What we’ll do is load the Excel sheet, pass in the parameters and use some calculated values on our resultign page. First things first: include the necessary class references:
/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . ‘./PHPExcel/Classes/’);
/** Class requirements */
require_once(’PHPExcel.php’);
require_once(’PHPExcel/Reader/Excel2007.php’);
PHPExcel is the base library which represents an in-memory spreadsheet. Since we need to interface with an Excel2007 file, we also include the required reader class.
Now load the Excel sheet into a PHPExcel object:
// Load price calculation spreadsheet
$objReader = new PHPExcel_Reader_Excel2007();
$objPHPExcel = $objReader->load(”price_calculation.xlsx”);
All data from the web form is passed in via the $_REQUEST array. Let’s pass these to the Excel sheet. I named all form fields equal to my defined names in Excel which makes coincidence of all array keys and cell names being the same intentional.
// Set active sheet
$objPHPExcel->setActiveSheetIndex(0);
// Assign data
$objPHPExcel->getActiveSheet()->setCellValue(’automaticTransmission’, $_REQUEST[’automaticTransmission’]);
$objPHPExcel->getActiveSheet()->setCellValue(’carColor’, $_REQUEST[’carColor’]);
$objPHPExcel->getActiveSheet()->setCellValue(’leatherSeats’, $_REQUEST[’leatherSeats’]);
$objPHPExcel->getActiveSheet()->setCellValue(’sportsSeats’, $_REQUEST[’sportsSeats’]);
This is actually about it. The only thing left is to fetch the formula’s calculated values and we’re done!
// Perform calculations
$_VIEWDATA[’totalPrice’] = $objPHPExcel->getActiveSheet()->getCell(’totalPrice’)->getCalculatedValue();
$_VIEWDATA[’discount’] = $objPHPExcel->getActiveSheet()->getCell(’discount’)->getCalculatedValue();
$_VIEWDATA[’grandTotal’] = $objPHPExcel->getActiveSheet()->getCell(’grandTotal’)->getCalculatedValue();
You can use these values to print the result on your web page:
Based on your chosen preferences, your car will cost <?php echo number_format($_VIEWDATA[’grandTotal’], 2); ?> EUR.
5. Summary
Embedding business logic in Excel and re-using it in PHP is not that hard. The PHPExcel library helps you simplify development: your application logic and business logic is separated. Business logic can be maintained by a business expert or key user in Excel. As an application developer, you can easily pass data in the sheet and make use of PHPExcel’s calculation engine.
More In Code
- A Guide to Cryptography in PHP
- 8 Best Open Source Shopping Carts
- Computer Random vs. True Random
- Make fancy buttons using CSS sliding doors technique
- Make fancy buttons using CSS sliding doors technique
Photoshop Tips - May 31, 2008 8:20 - 0 Comments
Popular Wealth - Free Photoshop Brushes To Download
Popular Wealth - Free Photoshop Brushes To Download
Free Photoshop Brushes
Getting the most out of your photoshop software requires plugins and tools like the following 300+ Free Photoshop Brushes that have graciously been made available for download by their authors. I Continue…
More In How to ?
- Reuse Excel business logic with PHPExcel
- 100 Ways to Save The Environment
- In Search of the Red Demon
- 15 Handy Google Search Tricks
- Multiple live CDs in one DVD
Wordpress - May 31, 2008 3:34 - 0 Comments
Thinking the Way Animals Do
Thinking the Way Animals Do
By Temple Grandin, Ph.D.
Department of Animal Science
Colorado State University
Western Horseman, Nov. 1997, pp.140-145
Temple Grandin is an assistant professor of animal science at Colorado State University. She is the author of the book Thinking in Pictures. Television appearances include 20/20, CBS This Morning, and 48 Hours. Dr. Grandin has autism, and her experiences have helped her to understand animal behavior. She teaches a course in livestock handling at the university and consults on the design of livestock handling facilities.
Unique insights from a person with a singular understanding.
As a person with autism, it is easy for me to understand how animals think because my thinking processes are like an animal’s. Autism is a neurological disorder that some people are born with. Scientists who study autism believe that the disorder is cause d by immature development of certain brain circuits, and over development of other brain circuits. Autism is a complex disorder that ranges in severity from a mild form Continue…
More In I LIKE IT !
- 49 Amazing Wallpapers
- The Phantom’s 50th
- 45 Photo Editing Tutorials for Photoshop
- Geek Cakes: For Geeky Wedding or Geeky Birthday
- LIGHTING