473,396 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to convert php output design into excel?

Exequiel
288 256MB
hello friends, how can i convert into excel file those output data came from my php and sql queries that has a fixed design using css? I'm done converting it into pdf, my only problem is that i want to have a copy of those data into excel.

Any comments are appreciated. Godbless. :)
Attached Images
File Type: jpg 2.jpg (65.7 KB, 130 views)
Oct 16 '14 #1
3 1525
Dormilich
8,658 Expert Mod 8TB
you can try to import the generated HTML file into Excel. however, bear in mind that those two (HTML and Excel) have totally different contexts. HTML is for displaying structured data (much like an image) while Excel is a spreadsheet application.
Oct 16 '14 #2
Exequiel
288 256MB
so far this are my code example on how to convert php data into excel. its working, it can convert now into excel. the only problem now is that how can i add styles to those data i have ? how to put bold to text? how to add background colors to headers? how to make text align centered?

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.   $data = array(
  3.     array("2-Jul" => "'06/07", "2C62 TT" => "=SUM(C3:D3)", "W" => 898, "Q" => 25, "∑W" => 25, "Ǭ" => 25, "2D43 TT" => 25, "W" => 25, "KFQ" => 3434, "FCAO" => 3434, "R-FCAO" => "=SUM(E3:F3)"),
  4.     array("2-Jul" => "'07/08", "2C62 TT" => "=SUM(C4:D4)", "W" => 444, "Q" => 890, "∑W" => 12, "Ǭ" => 678, "2D43 TT" => 3434, "W" => 676, "KFQ" => 3434, "FCAO" => 3434, "R-FCAO" => "=SUM(E4:F4)")
  5.   );
  6.  
  7.   function filter_data(&$str)
  8.   {
  9.     $str = preg_replace("/\t/", "\\t", $str);
  10.     $str = preg_replace("/\r?\n/", "\\n", $str);
  11.     if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"';
  12.   }
  13.  
  14.   // file name after download
  15.   $filename = "08 ~ 07 OF A DAY BEFORE YESTERDAY.xls";
  16.  
  17.   header("Content-Disposition: attachment; filename=\"$filename\"");
  18.   header("Content-Type: application/vnd.ms-excel");
  19.  
  20.   $ok = false;
  21.   echo "08 ~ 07 OF A DAY BEFORE YESTERDAY\n";
  22.   foreach($data as $row) 
  23.   {
  24.     if(!$ok) 
  25.     {
  26.       // display field/column names as first row
  27.       echo implode("\t", array_keys($row)) . "\n";
  28.       $ok = true;
  29.     }
  30.     array_walk($row, 'filter_data');
  31.     echo implode("\t", array_values($row)) . "\n";
  32.   }
  33.  
  34.   exit;
  35. ?>
by the way, thank you very much to the guidance @Dormilich. :)
Oct 17 '14 #3
Exequiel
288 256MB
I made it already, I'm finished, , I used table tag in html to put styles, :) I made it, and i'm done. :D
Oct 17 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: kscdavefl | last post by:
I am running the following code to retrieve a DataSet: public DataView CreateGroupSource() { string groupConnect = Session.ToString(); string groupSelect = "Select grpname from Maxusergroups...
2
by: iforsyth | last post by:
I'm doing a query against a database table and outputting to Excel via Response.ContentEncoding and Response.ContentType. Something like the code below where dg is a DataGrid control. ...
1
by: Patrick S. | last post by:
Hi, I wrote a small function, thaht converts a DataGrid to Excel from a Web-Application (C#). Running the function with 100-200 rows it just works fine. Starting a "special" Report produces a...
1
by: TaeHo Yoo | last post by:
How to convert a dataset to excel spreadsheet in windows based application?? Thanks a lot in advance. *** Sent via Devdex http://www.devdex.com *** Don't just participate in...
2
by: Ch Pravin | last post by:
Hi All: I am having the following xml which i need to convert to excel using xslt. Please help me out. Afghanistan.xml <?xml version="1.0" encoding="utf-16"?> <Languages...
2
by: John Bartley K7AAY | last post by:
When I output a table's values to XLS, one value in a very small table, and only one value, is changed. Here are the values in the table, tblLevel. LEVEL H-14 0 1 1.1
6
by: vamsioracle | last post by:
hi I have a report that displays the stock details. It is PDF format report. Now when i click on view output i want it to be in excel sheet. Is it possible Is there any other way to get the...
0
by: =?Utf-8?B?ZGlzcGxheW5hbWU=?= | last post by:
The following code used to outputs to Excel 2003 fine. Do I need to change it to output to Excel 2007? <% Response.ContentType = "application/vnd.ms-excel" Response.AddHeader...
0
by: zizi2 | last post by:
Hi, how do I output multiple excel files from one source using vbscript? Regards, Noluthando
1
by: reachravi70 | last post by:
Hello Users, I am new to PERL. There is a requirement to write a PERL script to query the Oracle data based on the user input date parameter and write the output to Excel. I have the following...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.