PHP - import data into a excel template - php

first off I am fairly new to php like 3 weeks working with it, and am loving it so far. Its a fantastic language.
I am running into a issue though, I have a client who wants the information collected in on a form on this website to then be imported into a excel documents that he already has created. Since I am fairly new I've been googleing for the past two hours and have come up with so many different answers that my head is spinning.
I was wondering if someone can instruct me if first this can be done and what is the best method.
Or if you know a website that might have already explained this in a simple way if you could direct me to that.
Thanks guys, hopefully someday I can be as smart as you :)
Peace

To start with, you're going to need a library capable of reading your Excel template, such as PHPExcel, which you can then populate with the data from the form and save

Hey Chris, Sounds like what you are needing to do is call a COM object (Excel automation), from PHP. I Googled calling COM objects from PHP and found a site that suggested doing something like this.. the sample is for word but it should be simple to translate the idea to excel.. As discussed below, can you assume windows? Is this code running against excel on the browser machine or against some excel data on the server?
<?
$word=new COM("word.application") or die("Cannot start word for you");
print "Loaded word version ($word->Version)\n";
$word->visible =1;
$word->Documents->Add();
$word->Selection->Typetext("Dit is een test");
New efficiencies lie ahead
See the new IBM System x3650 M3 Express$word->Documents[1]->SaveAs("burb ofzo.doc");
$word->Quit();
?>
Here is a link to using COM from PHP:
PHP: COM

Saving the data in a .csv (comma delimited) file may be a quick option if you can arrange the spreadsheet at all.

Our answer is to save them as is into the database and convert them to <BR> for display to a web page. That way if a non-web program looks at the data, it will display semi-correctly without change. Yes some things won't always display properly for the program, but they will for the web page.

Related

Extract from DB to XML

I have made a website where users can choose some regions on Google Maps, and save them into a database with a name an a description. What I need now is to be able to take the saved entries from my DB and show them also to an android app I have made with google maps. I am new to all these and from my research I understand that I should extract my data from the DB to an XML file and then parse them on the phone. For doing the first part I should use the following code, if I am not mistaken:
SELECT column1, column2,..
FROM tablename
FOR XML PATH;
What I still dont get is where should I put that piece of code? In a new file? All by itself? And with that code the XML file will be created, or should I do something else too?
Thank you
Well since noone answered my question and I did find the solution I'll post it here.
The answer is via PHP, XMLWriter. There is a question here that helped but I wasnt able to find from the beginning since I didnt know what to search for.

How to make report printing with Zend

I using Zend.1.7.2 in my project and i need report printing like Crystal report in
C# or VB.net. In first time I want it with function zend-pdf but i can't success with it.
so anyone can point me with a way that can print data out.
Note: my data is get from database.
Any help please, I am looking to see your reply soon.
Thanks
If you want something where you can design your report and fill it with information later, you can use PHPJasperXML which is an implementation of Jasper Reports on PHP, it exports to PDF and Excel and you can get it from here: http://www.simit.com.my/?q=PHPJasperXML

How can I write data to an excel table from textarea?

I am new in coding and sufferin from some basic issues. I searched for a topic to find the answer that I need but I could not find. I've been trying to write and searching codes for writting into xls file for 3 days but could not find a suitable one. The problem is:
I created a page with textareas and submit/reset button like that and I've got an excel table in document classgrades.xls. The colums of that table are named Name, Midterm1, Midterm2, Final, Attendance and Average.
Now, I am trying to write a code which automatically adds a new row and writes user inputs from textares into the excel table. If you help I appreciate very much and if you write the code briefly I can understand better.
The class I use to modify Excel documents is PHPExcel. Was at http://phpexcel.codeplex.com/ but I just googled and it's moved to GitHib https://github.com/PHPOffice/PHPExcel.
Small warning: I have found it occasionnally buggy (turn off "NOTICE" and "WARNING" errors before diving in, for example - or at least you did when I last used it) but otherwise it's easy to use.
It has some nice classes to navigate the workbooks and add rows. No point quoting examples here as there are lots of examples in the "test" section. https://github.com/PHPOffice/PHPExcel/tree/develop/Tests Use those and piece together what you need.

Should I be using some sort of database?

In an attempt to redesign a website, I put this page together by hand. However, there are currently over 100 more shows already that need to be added, and three new shows get added every year.
In the old system, a text document was used as a makeshift 'database'; it stored data about each show, with shows separated by '#' and data fields separated with ']'. Here's an excerpt:
#The Whorl of the Leaves]WhorlOfTheLeaves]3]F]167
#Aladdin]Aladdin]8]N]0
#A Christmas Carol]XmasCarol84-]7]N]0
#The Feral Child]FeralChild]7]N]118
#Camelot]Camelot]11]N]169
A PHP script was then used to extract the information about each show and make the page seen here.
I'm sure a script could be used to put together a page such as the one shown above, but it seems like there should be a better system than a text document to store the information.
My question is: if the text document 'database' is working, should I bother changing it? Is there a better way to organize the information about each show?
SQLite would be prefect for you. It's a tiny database that requires no configuration or setup - yet comes built into most PHP installs.
Just use PDO and your good.
$db = new PDO('sqlite:/path/to/here/mydb.sq3');
$db->query('SELECT * FROM shows');
Yep, there are a ton of "better" ways of doing this. But if you're happy with it and it works, why change it?
You could save yourself a lot of trouble by using a content management system such as drupal.

Parse PDF/DOC Bank Statement through PHP

I am working on a accouting application. The user will upload the desired pdf or doc bank statement in the application. I need to read/parse the document and insert the amount/cheque number etc...(according to my database structure) in the database.
Please help in achieving the same.
PDF is made for representation, not to work with the data inside.
You might be lucky with pdftotext or catdoc.
I've been working on this same issue for over 2 weeks now and I have to say it is quite a task. I have had some success finding a php class to extract the text , but the problem is it will not work on every version of the .pdf format it's hit and miss. And drumming one up yourself will take awhile figuring out the encoding and compression issues. Right now I'm actually looking at some python libraries. It's just too time consuming for me to write one of these up from scratch for now.

Categories