.  

 

 

.
.

23 / 03 / 2017

Usuarios conectados: 9

Cargando documento...

Buscar:

.

Este Sitio:

Principal

Dreamweaver

Fireworks

JavaScript

CSS

Sonido

Artículos

Links

E-ufemismos

Descargas

Historial

 

Mailing List:

Suscríbete a la lista de correo, No practico spamming y ofrece algunas ventajas.

Pulsa aquí para saber más y suscribirte.

 

Recomendados:

Tecnorama >Tutoriales Dreamweaver

 

Generate Excel files with DWMX/PHP/MySQL (part 1)

Versión para imprimir | Translate this page

Sometimes, it's very useful to give the user the ability to download data from your website. One of the most common formats is as *.csv file, which can be imported to many applications.

However: What if we generate an already formatted *.xls file, which could be already opened and saved by Excel? Besides data, we can give format to it and we'll give the user a ready to use spreadsheet!!

This article will show you how to generate an Excel file "on the fly", using DW, PHP and data from a MySQL database.

To achieve this, all you need is a blank php file and a table. No special libraries are needed. Ready? Let's start then.

1.- Add some code:
First of all, you need to add these lines at the very beginning of your document:

<?php
header("Content-Type: application/vnd.ms-excel");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
?>

And, If you want to give the user that "open or save" dialog box, simply add another line between the PHP tags (thanks Bergin for the tip):

header("content-disposition: attachment;filename=yourFileName.xls");

Now, give it a try: After you've written it, press F12 and see how Excel will open it.
Save the file (for example as "test_xls.php).

What have we done so far? We are telling the browser that the file we are sending will be an xls file despite its "php" extension, so it should call excel to open it, and make sure that previous content is not cached. That's all.
Now, we just need to put the data into it.

2.- Add a table:
Let's see what happens when we add a simple table to our document, just like the one above:



Hit F12 again: The spreadsheet now has data!

3.- Give it some format:
We can give the table the appearance that we want: You can modify the cells' width and background color, apply bold or italics to the text, change its font and color... Just use the property inspector to modify the properties (CSS Styles are not supported, sorry).

4.- Make it more dynamic:
We can also make the spreadsheet display dynamic results. For example, we can make it display the sum of Apples and Oranges automatically. Where's the trick? Well, simply adding Excel formulas to our table in DW:

Why B1:B2? Think of it this way: every cell in our table will be a cell in Excel, so the coordinates must match:

Modify the values for oranges and apples in the resulting Excel spreadsheet: Total is also updated!!

Important Notice: Remember that localized versions of Excel use different function names!: English versions use SUM() and Spanish versions, for example, use SUMA(). Be careful with this when you write them! However, you can write some code to find visitor's default language and change the function names. Any volunteers?...

Download sample file (English version):Just copy it into your PHP Site, open it with DW and hit F12 to test it. If you are running a localized version of MS Excel, you should change function names to make it work as expected

Next Part: Adding Data using MySQL

¿Comentarios? 186, de momento. Mostrando 1 ->5

1.- nba jersey sales ranking 2014 - Site discount infomation of offering cheap duke jerseys.

Hello there! This is kind of off topic but I need some guidance from an established blog.

Is it difficult to set up your own blog? I'm not very techincal but I can figure things out pretty
fast. I'm thinking about making my own but I'm not
sure where to begin. Do you have any tips or suggestions?

Appreciate it

2.- texas a&m jersey cheap soccer uniforms from china

3.- It is the best time to make some plans for the longer term and it is time to be happy. I have learn this put up and if I may I wish to counsel you few fascinating things or suggestions. Perhaps you can write next articles relating to this article. I want to read even more things apaoxrimptely it!

4.- Action requires knlogedwe, and now I can act! http://jpbgwxdd.com [url=http://tecwsgono.com]tecwsgono[/url] [link=http://sugywdx.com]sugywdx[/link]

5.- That's a knowing answer to a diucffilt question

« Previous | 1 - 5 | 6 - 10 | 11 - 15 | 16 - 20 | 21 - 25 | 26 - 30 | 31 - 35 | 36 - 40 | 41 - 45 | 46 - 50 | Next »

Añade tu comentario



Escribe el código de la imagen superior:

:

Tutoriales Dreamweaver

-El muy buscado Menú desplegable

-¿Qué $%&$% es 'SSI'?

-Utilizar tablas de excel para actualizar tablas en html.

-Plantillas en DW MX: Regiones opcionales.

-Adaptar tablas a la ventana.

-Vista diseño para formatos no reconocidos

-Carga de imagenes en orden

-Mi primera Extensión

-Rollover remoto ('Disjointed Rollover')

-Iframes vs. Frames

-Contenido dinámico en celdas

-DW MX: Repeating Tables

-DW MX: Practica el Cloaking

-DW MX: CSS en tiempo Diseño

-Buscar y Reemplazar en Dreamweaver

-Menú dinámico

-Collaborative Dreamweaver: Design Notes and Files Panel

-Using PHP Server Formats and MySQL Dates

-Creando un Newsticker

-Generate Excel files with DWMX/PHP/MySQL (part 1)

-Manejo de fechas en PHP y MySQL

-Generate Excel files with DWMX/PHP/MySQL (part 2)

-Manejo de Fechas en consultas a MySQL

-Showing all records by default in a results page (PHP)

-Retrieving data using AHAH (1)

-Retrieving data using AHAH (2)

-Retrieving data using AHAH (3)

TECNORAMA es simplemente una página personal. No sirve ni de promoción del autor ni cosas por el estilo.
Todos los códigos, textos y tutoriales son de libre uso mientras se mencione al autor (no es mucho pedir)
Este sitio es compatible con IE6/NS6/Mozilla1.0
Para contactar, puedes enviarme un e-mail a tecnorama@hotmail.com