I have a PHP code which will generate Graph & HTML table which is working fine. - Main_data.php
CSV output PHP is working fine. - CSV.php
Excel output PHP is working fine.
How to output all three reports when running Main_data.php?
I tried to include Csv.php in Main_data.php. I am not able to produce results from main_data.php.
Any suggestions on how to implement that function into my script?
Make functions displayGraph() and displayCSV().
Put them in one file by copying your codes from main_data.php and csv.php, include that file in a file you want to display graph and CSV from and execute the functions.
Related
So I've been working a bit with HTML2FPDF, and I have converting HTML to PDF working all fine. However, I cannot get any PHP to work. Not even static PHP like
echo "hello world";
it is just completely ignored. I thought this would render as HTML and it then would be included in the PDF, but it doesn't.
I wanna be able to run some PHP functions and then for the result to come out as HTML like it normally would. Is there a way to do this?
I am thinking that one way of doing this is to load the PHP function first. Then when the function has run and the result shows as HTML, then convert the page. I have tried this for a few hours now, with all sorts of solutions, but I can just not get it to work in any way.
Is there a way to convert PHP results to PDF as well?
Sounds like you don't have it installed properly.
You have just to launch the following command on the root folder of your project:
composer require spipu/html2pdf
Good morning.
I have a test.html file. I would like to convert into test.xlsx using php.
Now, I could create test.xls file using php, whereas it is having only html tags due to that this file could not open directly in excel and it shows extension error. so if the file is having test.xlsx format gets opened smoothly.
I did not know that how to proceed further to get an expected results.
Please help if possible.
Thanks in advance.
Best regards,
Balraj
Use PHPExcel_Reader_HTML function of PHPExcel
I would like to pull data from a mysql db.
This data is then inserted into a html file which is then converted to a pdf using dompdf.
The template is perfect and display's well when I run call dompdf.
However as soon as I try and insert php code, the template still shows perfectly, how ever the php code is displays nothing. If I open the page its shows, so I know it works.
In the options file I have done this :
private $isPhpEnabled = true;
my php file to call the template (LeaseBase.php):
<?php
$options = new Options(); $options->set('isPhpEnabled','true');
$leasefile = file_get_contents("Leases/LeaseBase.php");
$dompdf = new Dompdf($options); $dompdf->loadHtml($leasefile);
$dompdf->stream(); $output = $dompdf->output(); file_put_contents('Leases/NewLeases.pdf', $output);
?>
I also can't seem to pick up anything in the log files.
Any assistance is appreciated
However as soon as I try and insert php code, the template still shows
perfectly, how ever the php code is displays nothing.
Answer: It shows nothing because when a php page is executed, it outputs html (and not the php code). If you don't have an echo or print or any code that generates html code from the php script, the page will in fact be blank.
It's important to remember that php is serverside code WHICH CAN generate html code as long as you instruct it accordingly.
With versions of Dompdf prior to 0.6.1 you could load a PHP document and the PHP would be processed prior to rendering. Starting with version 0.6.1 Dompdf no longer parses PHP at run time. This means that if you have a PHP-based document you have to pre-render it to HTML, which does not happen when using file_get_contents().
You have two options:
First: Use output buffering to capture the rendered PHP.
ob_start();
require "Leases/LeaseBase.php";
$leasefile = ob_get_contents();
ob_end_clean();
Second: Fetch the PHP file via your web server:
$leasefile = file_get_contents('http://example.com/Leases/Leasebase.php');
...though, actually, if I were loading the file into a variable and feeding it to dompdf without doing any further manipulation I would use dompdf to fetch the file instead. In this way you are less likely to have to deal with external resource (images, stylesheets) reference problems:
$dompdf->load_html_file('http://example.com/Leases/Leasebase.php');
I really am trying to code from PHP to have a XML file. I got the code that can display items from PHPmyadmin. but how can I display those things in XML file is really my problem, I tried all the codes. I could find. But, still no luck.
While generating xml your first line in php file should be
header ("content-type: text/xml; charset=utf-8");
then use echo statement & print whatever you want within xml tags like
echo "<status>0</status>";
just follow xml standerds & test using IE will be better.
I want to pre-append some text a a CSV file that is created by MySQL.
Basically I want to add the header information for the rows so when the user opens it in Excel they know what each column is.
Whats the best way to do this. I presume there is some easy linux command that can do this? I can also do it in the PHP script. I'd like to know how to do both just for educational purposes.
General setup:
Debian Etc
LAMP website
Cron calls a PHP script which creates the csv file every night.
Thanks,
Derek
You can do for example this:
echo "header information" | cat - data.csv > dataInfo.csv
echo prints the header, cat takes this header from standard input and writes it together with everything from data.csv then into dataInfo.csv
Instead of pre-pending the header text to the data file, start with file which contains the header and then append the data/CSV file to this header file.