473,499 Members | 1,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

exporting reports into excel file using php

121 New Member
hello,

i want to export reports into excel file,
i got some class files which will export into excel file.
Now i need to change the font size, font should be in bold.

how i can do that one.
Jul 25 '08 #1
2 3968
r035198x
13,262 MVP
Where did you get the class files from? You probably need to change those files or ask where you got those files from.
Jul 25 '08 #2
sbettadpur
121 New Member
I downloaded from the internet, they are using some class files.

1) class.export_excel.php
2) export_report.php


1) class.export_excel.php

source code of class.export_excel goes like this....................


Expand|Select|Wrap|Line Numbers
  1. <?php
  2. #### Roshan's very simple code to export data to excel
  3. #### Copyright reserved to Roshan Bhattarai - nepaliboy007@yahoo.com
  4. #### if you find any problem contact me at http://roshanbh.com.np
  5. #### fell free to visit my blog http://php-ajax-guru.blogspot.com
  6.  
  7. class ExportExcel
  8. {
  9.     //variable of the class
  10.     var $titles=array();
  11.     var $all_values=array();
  12.     var $filename;
  13.  
  14.  
  15.     //functions of the class
  16.     function ExportExcel($f_name) //constructor
  17.     {
  18.         $this->filename=$f_name;
  19.     }
  20.     function setHeadersAndValues($hdrs,$all_vals) //set headers and query
  21.     {
  22.         $this->titles=$hdrs;
  23.         $this->all_values=$all_vals;
  24.     }
  25.     function GenerateExcelFile() //function to generate excel file
  26.     {
  27.  
  28.         foreach ($this->titles as $title_val)
  29.          {    $b = 0x0190;
  30.              $header .= $b.$title_val.$b."\t";
  31.          }
  32.          for($i=0;$i<sizeof($this->all_values);$i++)
  33.          {
  34.              $line = '';
  35.              foreach($this->all_values[$i] as $value)
  36.             {
  37.                  if ((!isset($value)) OR ($value == ""))
  38.                 {
  39.                      $value = "\t";
  40.                  } //end of if
  41.                 else
  42.                 {
  43.                      $value = str_replace('"', '""', $value);
  44.                      $value = '"' . $value . '"' . "\t";
  45.                  } //end of else
  46.                  $line .= $value;
  47.              } //end of foreach
  48.              $data .= trim($line)."\n";
  49.          }//end of the while
  50.          $data = str_replace("\r", "", $data);
  51.         if ($data == "")
  52.          {
  53.              $data = "\n(0) Records Found!\n";
  54.          }
  55.         //echo $data;
  56.         header("Content-type: application/vnd.ms-excel");
  57.         header("Content-Disposition: attachment; filename=$this->filename");
  58.         header("Pragma: no-cache");
  59.         header("Expires: 0");
  60.         print "$heading\n$header\n$data";
  61.  
  62.  
  63.     }
  64.  
  65. }
  66. ?>
  67.  

2) export_report.php



Expand|Select|Wrap|Line Numbers
  1. <?php session_start(); ob_start();
  2.  
  3. #### Roshan's very simple code to export data to excel
  4. #### Copyright reserved to Roshan Bhattarai - nepaliboy007@yahoo.com
  5. #### if you have any problem contact me at http://roshanbh.com.np
  6. #### fell free to visit my blog http://php-ajax-guru.blogspot.com
  7.  
  8.     //code to download the data of report in the excel format
  9.     $fn=$_GET['fn'].".xls";
  10.     include_once("class.export_excel.php");
  11.     //create the instance of the exportexcel format
  12.     $excel_obj=new ExportExcel("$fn");
  13.     //setting the values of the headers and data of the excel file
  14.     //and these values comes from the other file which file shows the data
  15.     $excel_obj->setHeadersAndValues($_SESSION['report_header'],$_SESSION['report_values']);
  16.     //now generate the excel file with the data and headers set
  17.     $excel_obj->GenerateExcelFile();
  18.     //print_r($_SESSION['report_values']);
  19.  
  20. ?>




I go through it but i don't know where I have to make changes in the source code

Please have a look of both files and give me some idea

Thank you
Jul 25 '08 #3

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

Similar topics

3
4259
by: Andres Romero | last post by:
I have a button in my html page for exporting to excel files using the RenderControl function. When the table generated is small in rows size it works fine, but when there are much more rows (more...
2
1756
by: | last post by:
Greets, How does one connect to a local excel file using data wizard is it possible? I'm trying to connect to an excel file and populate a dataset and combo box with the data from excel TIA
4
5091
by: Reny J Joseph Thuthikattu | last post by:
Hi, Can any one guide me to read an excel file using vb.net? Reagrds Reny --- Outgoing mail is certified Virus Free.
5
20026
by: Narendar123P | last post by:
Hi all, I am trying to plot a graph in excel file using C#.Net. I am using the name space excel . If my graph has one series(2 columns), i am able to draw the graph. if my graph has two series(4...
0
1236
by: newUser1234 | last post by:
I'm trying to read and write from an excel file using this method..My application can read the excel file without problems but doesn't write anything to the file i want it to write. I've also tried...
2
3990
by: mangalamonkey | last post by:
I want to export data into an excel file using iReports.I could do that but the data is displayed as an image. I need the data to be displayed as cells as in the excel sheet. plz do reply.........
1
2687
hidash
by: hidash | last post by:
hi everyone, i need some help in opening excel and word file using poi filesystem. i have created a new word and excel file using poi. but i am struggling to open the existing file using poi. pls...
1
2687
by: SagarDoke | last post by:
I have a txt file. I want to add the data from that file into the excel file using java. That data is delimited by spaces as follows: 1 Sagar Doke Address Roll No. City 2 ABC ...
2
5255
by: veer | last post by:
Hi i want to open excel file using vb.net . The file is passsword protected and i know the password when i used to open the file with out password it works fine and open but when the file with...
1
2843
by: baburmm | last post by:
Hi all, Can any one tell me, Export datas to a Excel file using query without openrowset method is there any other methods are posible for creating an Excel file to export it Thanks,...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7229
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...
1
6905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7395
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5485
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,...
1
4921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.