1 Media Software Design DIG 3134 Fall 2011 Lecture 18: Excel, PDF J. Michael Moshell University of Central Florida Original image* by Moshell et al.

Slides:



Advertisements
Similar presentations
The Web Wizards Guide to Freeware/Shareware Chapter Four Essential Tools for Web Page Authors.
Advertisements

Adding Dynamic Content to your Web Site
1 Caching in HTTP Representation and Management of Data on the Internet.
. Website and file organization. How websites work.
HTML Form Processing Learning Web Design – Chapter 9, pp Squirrel Book – Chapter 11, pp
The Web The World Wide Web What does it do?.
Web Servers How do our requests for resources on the Internet get handled? Can they be located anywhere? Global?
What’s a Web Cache? Why do people use them? Web cache location Web cache purpose There are two main reasons that Web cache are used:  to reduce latency.
6/22/ Final review. 6/22/ Excel (questions similar to homework) –Spread sheet questions: Creating formulas.
HTTP Overview Vijayan Sugumaran School of Business Administration Oakland University.
Nikolay Kostov Telerik Corporation
FILE UPLOADS CHAPTER 11. THE BASIC PROCESS 1.The HTML form displays the control to locate and upload a file 2.Upon form submission, the server first stores.
CLEW Basics Lorie Stolarchuk Learning Technology Trainer Centre for Teaching and Learning 1.
8/17/2015CS346 PHP1 Module 1 Introduction to PHP.
Creating a Web Page HTML, FrontPage, Word, Composer.
1 DIG 3134 – Lecture 3 Forms Michael Moshell University of Central Florida Media Software Design.
Computer Concepts 2014 Chapter 7 The Web and .
Wikispaces in Education Tutorial Jennifer Carrier Dorman
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
AIT 616 Fall 2002 PHP. AIT 616 Fall 2002 PHP  Special scripting language used to dynamically generate web documents  Open source – Free!!!  Performs.
Copyright © 2003 Pearson Education, Inc. Slide 1-1 Web Design & Development PHP.
Krerk Piromsopa. Web Caching Krerk Piromsopa. Department of Computer Engineering. Chulalongkorn University.
IPAD Set Up. Gmail Account First, you need to set up a free gmail account with your name. If you have an existing one you may use that as long as: – A)
FTP (File Transfer Protocol) & Telnet
CSC 2720 Building Web Applications Getting and Setting HTTP Headers (With PHP Examples)
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
CP476 Internet Computing Lecture 5 : HTTP, WWW and URL 1 Lecture 5. WWW, HTTP and URL Objective: to review the concepts of WWW to understand how HTTP works.
TCP/IP Protocol Suite 1 Chapter 22 Upon completion you will be able to: World Wide Web: HTTP Understand the components of a browser and a server Understand.
Dr. Hala Fawzi  Make sure you are signed into Wikispaces  Go to: 
Python CGI programming
10/5/2015CS346 PHP1 Module 1 Introduction to PHP.
1 In the good old days... Years ago… the WWW was made up of (mostly) static documents. –Each URL corresponded to a single file stored on some hard disk.
Follow the Data Data (and information) move from place to place in computer systems and networks. As it moves it changes form frequently. This story describes.
Electronic Mail. Client Software and Mail Hosts –Client PC has client software that communicates with user’s mail host –Mail hosts deliver.
Fall 2005 Using FrontPage to Enhance Blackboard - Darek Sady1 Using FrontPage to Enhance Blackboard 1.Introduction 2.Starting FrontPage 3.Creating Documents.
Chapter 9 How Do Users Share Computer Files?. What is a File Server A (central) computer which stores files which can be accessed by network users.
AUTO-BUSINESS HOW DO WE USE HYPERLINKS?. Edit an image that represents a hyperlink If a picture, AutoShape, or other graphic is used to represent a hyperlink,
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
14. Uploading Files to MySQL Database. M. Udin Harun Al Rasyid, S.Kom, Ph.D Desain dan.
More on Variables Some related techniques. Header() function void header ( string $string [, bool $replace = true [, int $http_response_code ]] ) header()
Dynamic web content HTTP and HTML: Berners-Lee’s Basics.
CS 4720 Dynamic Web Applications CS 4720 – Web & Mobile Systems.
Wikispaces in Education Tutorial Fatema Kashoob Nawal ALKathiri
The Internet 8th Edition Tutorial 3 Using Web-Based Services for Communication and Collaboration.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
1 Media Software Design DIG 3134 Fall 2012 Lecture 15: Graphics J. Michael Moshell University of Central Florida Original image* by Moshell et al.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The Basics of Managing Your Department Website March 8, 2012.
SESSIONS 27/2/12 Lecture 8. ? Operator Similar to the if statement but returns a value derived from one of two expressions by a colon. Syntax: (expression)
PHP and Sessions. Session – a general definition The GENERAL definition of a session in the “COMPUTER WORLD” is: The interactions (requests and responses)
1 DIG 3134 Lecture 6: Maintaining State Michael Moshell University of Central Florida Media Software Design.
Wikispaces in Education Tutorial ESA, Region 2 Mary Teply Marge Hauser.
1 DIG 3134 Lecture 8: Reading and Writing Text Files Michael Moshell University of Central Florida Media Software Design.
CACHING TO IMPROVE PERFORMANCE
TechKnowlogy Conference August 2, 2011 Using GoogleDocs for Collaboration.
 Open the course to add an online class  Click on Add a Page (left side)  Type in a name  Click on Create  Click on the Content Tab  Click on Add.
Finally getting to html and CSS… Tim Berners-Lee, the writer of the software program that makes him the inventor of the WWW, defines the Internet as a.
Block 5: An application layer protocol: HTTP
How Works Ameera Al Ghamdi ID:
Web Development Web Servers.
PHP / MySQL Introduction
ACT102 Introduction to web design
Module 1 Introduction to PHP 11/30/2018 CS346 PHP.
ACT102 Introduction to web design
How Works Ameera Al Ghamdi ID:
Follow the Data Data (and information) move from place to place in computer systems and networks. As it moves it changes form frequently. This story.
HTTP Hypertext Transfer Protocol
The Internet and Electronic mail
Presentation transcript:

1 Media Software Design DIG 3134 Fall 2011 Lecture 18: Excel, PDF J. Michael Moshell University of Central Florida Original image* by Moshell et al.

-2 - Four Easy(?) Add-ons for PHP 1. Creating Excel (.xls) files 2. Reading Excel files 3. Uploading files 4. Creating PDF documents

-3 - Creating an Excel file CREATING Excel: My method is ONLY useful for downloading to the browser – NOT for storing a file directly to disk on the server. NOTE: This code will NOT work if anything, even a single character, is emitted by the PHP code before the 'emitxls' function is called.

-4 - Creating an Excel file function emitxls($data) { header("Content-type: application/octet-stream"); # from: forge.typo3.org/issues/show/3765 header("Content-Disposition: attachment; filename=output.xls"); header('Pragma: public'); header("Expires: Mon, 26 Jul :00:00 GMT"); // Date in past header('Last-Modified: '.gmdate('D, d M Y H:i:s'). ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: pre-check=0, post-check=0, max-age=0'); echo $data; } #emitxls

-5 - Creating an Excel file ///// MAIN PROGRAM ///// $t="\t"; // Tab character $n="\n"; // Newline character $data="Line 1".$t."column 2".$t."column 3".$n; $data.="Line 2".$t."l2 column 2".$t."l2 column 3".$n; $data.="Line 3".$t."l3 column 2".$t."l3 column 3".$n; emitxls($data); ?>

-6 - A Demo that Doesn't work Here's one that DOES work: xlsdemo1.php <?php // etc Here's one that DOES NOT work: just add a space at top of xlsdemos <?php //etc NOTE: The response VARIES from one Apache environment to another. (Sometimes error message; sometimes text on screen.) Sometimes hard to notice the blank line at top

-7 - Moving on... how to READ Excel. I use a small library called excel_reader2.php. It uses PHP Objects, as follows: $data = new Spreadsheet_Excel_Reader($filename); // This Spreadsheet_Excel_Reader is a CLASS defined in the excel_reader library. // Now we use two accessor functions to find out how big the spreadsheet is $colcnt=$data->colcount(); $rowmax=$data->rowcount();

-8 - Reading an Excel File (Local) Demonstrate and experiment with xlsdemo2.php Items to note: 1) This function does NOT ask the user to upload an Excel file. It works with a file that is local to the PHP code. So this operation is not 'symmetric' with the code to emit a file, that I gave you previously. 2) If the file is not found, or if it's defective, you will get a zero value for 'rowmax'. Note the error message in my getspreadsheet function.

-9 - Uploading a file (image) Demonstrate and experiment with upload.php Items to note: 1) $_FILES is analogous to $_POST or $_GET i. e. it's a "built-in global array". 2) I've not yet managed to get an error, so haven't seen "Error Return Code" in action. 3) Functions to understand: end, in_array, file_exists, move_uploaded_file

-10 - Uploading a file (excel) Demonstrate and experiment with uploadexcel.php Items to note: 1) I simplified it considerably from upload.php 2) I used !$target to tell if this was the first pass, and to emit the form if this was the case. 3) This one DELIBERATELY overwrites workfile.xls, because you will presumably now use the excel_reader2.php library to pull workfile.xls into your software for whatever purpose....

-11 - Producing a PDF File Somewhat similar to Excel production, in that the PDF can be sent to the browser. BUT you can also save a copy of the PDF file on your host. Somewhat similar to the Excel reader, in that a special library is used. BUT the library is much bigger and more complex. (18 megabytes) Tour the tcpdf website at

-12 - PDF Example 1 There are many examples at See my pdfdemo1.txt Example 1 uses the writeHTMLcell( ) function, which allows you to use HTML to format your text. BUT HTML has substantial limits for formatting! (e. g. font control.)

-13 - PDF Example 2 Read the code. Understand these methods: $pdf->SetFont() $pdf->AddPage(); $pdf->Text() $pdf->Line() $pdf->Output()

-14 - The Output method Send the document to a given destination void Output ([string $name = ''], [string $dest = '']) string $name: The name of the file. If not given, the document will be sent to the browser (destination I) with the name doc.pdf. string $dest: Destination where to send the document. It can take one of the following values: I: send the file inline to the browser D: send to the browser and force a file download with the name given by name. F: save to a local file with the name given by name.

-15 - cURL When a PHP program needs to invoke another Internet site client URL Library supports http, https ftp, gopher, telnet, dict, file, ldap proxies, cookies, user-password authentication

-16 - cURL Demonstrate cURL: -mograb.php = A PHP program that reads another website and "screen scrapes" some information.

-17 - cURL in action Browser The mograb.php 'scraper' program Program sends an http message via CURL The scraped Site "goldprice.html" Access a URL to run PHP program

-18 - cURL in action Browser The mograb.php 'scraper' program Program sends an http message via CURL The scraped Site "goldprice.html" Access a URL to run PHP program Server Returns the text Of goldprice.html CURL sends reply to calling program

-19 - cURL in action Browser The mograb.php 'scraper' program Program sends an http message via CURL The scraped Site "goldprice.html" Access a URL to run PHP program Server Returns the text Of goldprice.html CURL sends reply to calling program Mograb creates html to deliver the scraped information Plus whatever else you want To tell your user.

-20 - cURL demo 2 Demonstrate cURL: -Mograb2.php This just shows that cURL can call a website that is not just in localhost (namely,

-21 - cURL demo 3 Demonstrate memcheck.php A little "fake" membership checking site > Joe Wilson > Mary Lebone anything else ->NOT a member -Mograb3.php

-22 - Summary of Lecture Emit XLS: Just a header and some tabs and newlines Read XLS: A small (free) library of PHP code Upload files: Write PDF: A large (free) library with many capabilities Link to other websites: A built-in PHP capability called cURL

-23 - PROJECT 3 – Clean-Up! If you DO NOT SEE PROJECT 3 in the grades-ranked.xls chart

-24 - PROJECT 3 – Clean-Up! If you DO NOT SEE PROJECT 3 in the grades-ranked.xls chart and if you DID NOT GET FROM ME (about your project)

-25 - PROJECT 3 – Clean-Up! If you DO NOT SEE PROJECT 3 in the grades-ranked.xls chart and if you DID NOT GET FROM ME (about your project) We must fix it TODAY or it's gone --- time to focus on Project 4 and Final Exam