Mapping Excel Sheet Field with my pre defined database fields php - php

I am having a number of different excel sheets at my end. I need to put their data in the database. There are some predefined fields in database (country,code,start date, end date) which I need to fetch from excel and need to put in the database.
Tried so far :
I have fetched the data and putting it in the database when i know the field names of excel sheets. For example if excel is also having (country,code,start,end) then my code is taking and putting in the data base exactly
Problem
I want this to be automatic upload to database in case the excel fields are not same as i using in my code. Explaining furhter , suppose in my excel fields are (location,location code, starting date, end date). then I also want my program to extract the data from proper field.
I want some kind of mapping utility at my panel so that admin can map the fields once a new excel sheet with new fields are uploaded. so that it maps and fetch the data from proper columns of excel sheets.
Please suggest how to start it with.
Thanks,

You can use library like
http://code.google.com/p/php-excel-reader/
And do a custom app which have admin can select the fields in db for the read columns in excel.

Related

How to import Wordpress database to pure PHP MySQL website?

I am currently in a project which develops (actually re-designs) a news company website. Their old website had been developed using Wordpress (Latest version). And, now we are developing brand new custom design website using PHP and MySQL. But, they have over 10,000 news (posts) on old wordpress database. All I need to know is, how do we import all those post data to our main database? Our database and table structure is way different from wordpress one. Are there any SQL commands to import just only single or couple of columns data and paste them to another database table? Your help is highly appreciated.
Pull them down into a CSV, update the fields as required, import them into MySQL...
A CSV is a file of Comma separated values: https://en.wikipedia.org/wiki/Comma-separated_values
Plugin to get Posts as CSV: https://wordpress.org/plugins/simple-csv-xls-exporter/
Edit the field names (in a text editor or something that can edit CSVs and save them correctly), remove data you don't require etc etc. then import into your database.
Here's a handy link to import CSV into MySQL: How to import CSV file to MySQL table
Does that make sense?
If you know how to use MySQL , you make queries that can fetch the data and like that you can fetch all the data from MySQL import it in a way that you need in your new website and export it there. if You don't understand.
Step 1 :
Know that is required this is very basic step, you should know what you need and make a list of it.
Step 2 :
Make MySQL queries and fetch the data according to your database structure, use excel if your not so good in MySQL , organized as data as requirement
Step 3:
Now you will have all the data, you can either convert that to csv or sql format and insert in to your database easily.

Export Excel sheet data to already existing database by adding new field

I have a table which has data already with many fields. Now I want to add another field and for that field I want import data from Excel sheet. Is it possible to import data from Excel sheet to an already existing table or should I create a new table for importing data from Excel sheet?
You might want to take a look at PHPExcel - i's a library that lets you create new Excel files and read existing Excel files. It's very well documented, you shouldn't have any problems.
Once you've retrieved your data from the Excel file, use a simple INSERT INTO statement to insert these data in your database.
Good luck! :)

Export Mysql data to a customized XLS file using php

First of all, I do know the process of exporting MySQL data to excel file using php. But I have some specific requirement and I want to know if it can be done or not. I have already googled, but didn't get any specific information or method regarding the same.
This is my xls template :
Overview:
Column C is fixed and others are scrollable.
There are basically couple of organizations.
Data starting from COL-C8 to COL-L8 is exactly stored on a MySQL Table of an organization (e.g. Organization1).
Data of COL-C1 to COL-C5 & D1 to D5 is on another MySQL Table of Organization1.
So for every organization there are 2 different MySQL tables.
Requirement :
The goal is to export data from MySQL and add it to the excel file according to the image above.
Problem :
Adding data from MySQL table to excel is pretty easy if the requirement is to just replicate same on the excel sheet. But I have no idea how to do this customization.
Like pulling data from two different tables and adding them to different columns in an excel sheet.
Please let me know if it is possible. And if yes, then kindly direct me to some references on how to achieve this.
Thank You!
Try PHPExcel. This library allows you to read and write from/to .xls files.

program to convert sheet1(excel) into standard sheet2(excel)

Is it possible to write a program that change the order of columns in sheet1(excel) based on a table in standard sheet2(excel)?
Sheet1 have the same header of each column as sheet2 but the position of columns is not same and also it is possible that some more columns are present in sheet(1). Finally I have to store the standard sheet into the database.
Yes it possible to change the order of columns.
Steps:
Change the excel sheet format file to csv file.
Write a PHP code to arrange the random columns as per the standard sheet.
Write a code to enter this data into the database. Each time you receive the new column append it at the last of the standard column.
Make the respective change in the PHP code for the same.
This is probably a dumb answer, but back in the day I used VB code inside of Excel workbooks to manipulate data including culling information from one worksheet and creating another based on contents.
Try http://msdn.microsoft.com/en-us/library/office/ee814737(v=office.14).aspx for more information.

How to populate Excel Spreadsheet with MySQL Data using PHP

Let's go ahead and get this out of the way - i realize I can generate tables with php and mysql and output in 'almost' any format I need but in this scenario, the excel spreadsheet is formatted in some strange ways (layout, color, etc) and the client won't budge. I have to use the exact excel spreadsheet.
I am trying to pull data from a mysql database with php calculations behind it and populate various cells within an Excel file. Is it possible to do this?
Thank you ahead of time
You can try PHPExcel ( http://phpexcel.codeplex.com/). I think this is what you are looking for.

Categories