Stop excel from auto-formatting data

A collection of tutorials and posts that show additional functionality of MATE

Moderator: KarelB

Stop excel from auto-formatting data

Postby admin » Thu Sep 29, 2011 4:23 pm

The other day I ran into the problem where excel was auto-formatting a column of data that had some very long numbers. It would truncate them or turn them into scientific notation which is not what I wanted. So after searching the net for a while I finally found a solution that works. This method should work with any type of data such as dates etc. Basically you need to trick excel into thinking the data is a formula and then it won't try to format it. Here is the code to do it with mate but it should work with any export script.

Code: Select all
function excelFormula($col,$val,$row)
{
    return '="'.$val.'"';
}

$tableColumns['column_name'] = array('display_text' => 'Column Name', 'perms' => 'TXQSFO', 'csv_export_fun' => array(&$this,'excelFormula'));
admin
Site Admin
 
Posts: 1502
Joined: Fri Jul 11, 2008 1:34 am

Return to How To

Who is online

Users browsing this forum: No registered users and 5 guests

cron