Exporting from PHP to Excel - cell formatting - php

I am exporting data from a database to an Excel file using PHP and a Codeigniter to_excel helper.
Everything is working correctly, except I have a field that contains data in the format of 1-1, 2-1 etc. When I open the file in Excel, Excel is automatically formatting this data as a date field so that it appears 01-Jan, 02-Jan etc.
Is there a way to force Excel not to format this data as a date field?
Thanks.

Preface the data with a single apostrophe so that Excel treats it as text. This needs to be done before it is opened in Excel.

Related

CI Export CSV data formating issue

I'm learning PHP & CodeIgniter 3. In this project I need to export some data to a CSV file. I'm able to export the CSV file, however the data is displaying incorrectly in a couple columns. Example (5.32856E+11) where it should be (532856165001). I'm able to see the actual value if you double click the cell.
Is there anyway to force the data in a CSV to display the data correctly?
This is the microsoft excel formatting and does not have any relation with your code just try to regenerate your csv and then re-open your file with a simple text editor (notepad++ or sublim text)

Read unformatted csv, and convert to formated csv via php script

The Goal is to extract data of a specified column or CSV using PHP,
I have a unformatted CSV.
I format this csv using Excel Feature: Data->Import Data from Text,
(Using delimiter and tab as a separator) it format the data into columns.
For this i have created a Excel Macro.
Any ideas on how to execute excel macro via php script?
That code will execute the Macro and CSV will be well formatted and then i can get the data.
Any help will be highly appreciated.

In php how to read the csv file using excel and know the data format of the each columns

I have some csv file and want know the data format i.e data type of the csv columns .its not possible from direct csv file .so that i would like to read a csv file in micro soft excel and know the data format of each columns. i need to done these steps using php.
Is there any way?

Export the fetched database data to PDF or Excel format

I want to export fetched data from my database to pdf format or excel format.
Can someone help me out with a simple example?
It would be easiest to use CSV which means Comma Separated Values and that's exactly what it is.
For example:
Name,Surname,Birth year
John,Doe,1990
It will become a table if opened with Excel or other Calc software.
Also it is a good practice to have text surrounded by quotes, because it's required if the text contains commas.
So final version:
"Name","Surname","Birth year"
"John","Doe","1990"
The file should be in .csv format.

Extracting BLOB data from Excel with PHP

I have an excel with data exported from one MSSQL database.
I want to get the data out of this file. The filereading is easy, everyone could do it, but is there any special work I have to de around the BLOB field to take it out safe and put it in a file.
This field contains either a HTML or a RTF file (i have another field which tells me if it is HTML or RTF).

Categories