Entering values off an Excel file onto multiple web-sites? Anybody know of any short-cuts?
A big part of my job involves manually entering values off of an Excel spreadhseet into different companies' websites for the purpose of generating information. Each companies' website looks different, but the values that I am entering are always the same. Are there any shortcuts that I could use to save time, since I often have to enter the same information into as many as 5 different websites? One of the sites has an Excel upload feature, but the other 4 do not. Is there any way to work around this?
Public Comments
- Yes, there is a shortcut: PHP. PHP is not too hard to learn. a bit more complicated than HTML, but not too bad. It is a scripting language, so it can be stuck right into an html webpage. So here's what you do. If this data is to be presented as a table, that is fine-PHP can build tables for you on the fly. First, you will export the data in the excel file to a CSV file. Now, this data can be sent to multiple website-the same data. The CSV file will be compact (unless we are talking about a mountain of data here), and should load quickly. Now here is a little bit of PHP code to get you started: <?php //this next line reads in data from your external csv file- $file = "data.csv"; $counter = 1; //as you can see, php can utilize CSS to make your stuff fancy- $htmlStr = "<link href=\'style.css\' rel=\'stylesheet\' type=\'text/css\'>\n"; $lines = file($file); if(file_exists($file)){ $htmlStr .= "<table border=1 cellspacing=0 cellpadding=1>\n"; foreach ($lines as $line_num => $line) { $str = explode(',',$line); if($line_num == 0){ //header row $htmlStr .= "<tr>"; foreach ($str as $key => $value){ $htmlStr .= "<td colspan='8' align='center' bgcolor='black'><font color='white'><b>$value</b></font></td>"... } $htmlStr .= "</tr>\n"; } elseif($line_num == 1){ //titles row $htmlStr .= "<tr>"; foreach ($str as $key => $value){ $htmlStr .= "<td><font color='black'><b>$value</b></font></td>"... } $htmlStr .= "</tr>\n"; } else { //data row 2 $background_color = ( $counter % 2 == 0 ) ? ('white') : ('#99FF00'); $htmlStr .= "<tr bgcolor ='".$background_color."'>"; foreach ($str as $key => $value){ $htmlStr .= "<td align='center'>$value</td>"; } $counter++; $htmlStr .= "</tr>\n"; } } $htmlStr .= "</table>\n"; $lines = count(file($file)); } else { $htmlStr = "No data available."; } echo $htmlStr; ?> So what this little bit of code does is to read in data from an external file-your csv file. This particular bit of PHP actually puts the data into a table. There is a 'counter' in there that is incremented for each line. It is checked, and if the line number is divisible by 2 without a remainder (an EVEN number, in other words!), it makes the background of that line white; otherwise it is color #99FF00 (kind of a green). You would put this php in your html, or run it as its own page. It reads in the data, and you are displaying external, dynamic content! Now, if the data changes, you simply put a new CSV file in place and refresh the screen-instantly, and without pain, your new data is being displayed. No more changing tables, or even worse, trying to drag/drop an excel table into HTML. One other thing. If you embed a php snippet into an existing HTML page (which is fine), you will have to change the html files extension from .html to .php - There is a way around this, but I haven' put in the time to figure it out, so I just change the file name. Now, when you save your excel data as a CSV file, excel may throw extra commas into your saved file. So it is a good idea to open up your CSV file in a text editor (or your HTML editor) and delete the EXTRA commas. Since this is a 'comma separated value' file, make sure you leave the commas in between each of the data bits! (in my example, there would be no comma at the end of a line-PHP would see this as the end of a row and start a new row). PHP is pretty flexible-it can do a LOT. There are tons of sites and forums that can help you. If you can understand HTML, you can figure out PHP. Here's a good place for more PHP info: http://www.php.net/ Hopefully this helps!
Powered by Yahoo! Answers