Page 1 of 1

CSV export help

Posted: 21 Mar 2005, 07:36
by mantisuser
How can I get the description field to be part of the CSV export in mantis? Does this require customization or is it part of the standard feature?

Posted: 17 Nov 2005, 23:21
by webwesen
I am trying to do the same...

in custom_functions_inc.php :

Code: Select all

 
function custom_function_override_get_columns_to_view( $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
                $t_columns = array();

                if ( $p_columns_target == COLUMNS_TARGET_CSV_PAGE ) {
                ...skip...
                        $t_columns[] = 'description';
                ...skip...
               }
}

function print_column_title_description ( $p_sort, $p_dir, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE )
{
    if ( $p_columns_target != COLUMNS_TARGET_CSV_PAGE )
    {...skip...}
    else
    {
        echo lang_get( 'description' );
    }
}

function csv_format_description( $p_description )
{
    return csv_escape_string( $p_description );
}
now is only custom_function_override_print_column_value left.

any suggestions?
I have read Victor's blog entry on customization, but it doesn't help me much in this case...

thanks in advance

edit: curly brackets are all messed up with a [ code ] tag... Preview shows them fine though.

Posted: 22 Nov 2005, 17:30
by webwesen
for the benefit of other noobies like myself...

what I ended up doing is (not sure if it is the best way - am a php noobie as well):

csv_export.php :

Code: Select all

                                $t_function = 'csv_format_' . $t_column;

                                # patch start
                                if ( $t_column === 'description' )
                                {
                                        $f_bug_id = $t_row ['id' ];
                                        $t_bug = bug_prepare_display ( bug_get ( $f_bug_id , true ) );
                                        echo $t_function( $t_bug->description );
                                }
                                else
                                {
                                        echo $t_function( $t_row[ $t_column ] );
                                }
                                # patch end

and have edited the resulting output in csv_format_description(), so no html is printed out (like  )

Posted: 18 Mar 2006, 17:11
by ktang
Tried the way webwesen did. It does works well.

However, I got a new problem. Lines will not be broke in the exported .csv file if the reporter uses hard return to make sentences/strings in lines in the Summary field. Open the .csv file in MS Excel, layout would be in a mess with "<br />" there, but no line breaks in the cell.

Any ideas?

Thanks,

Kelvin

Posted: 21 Mar 2006, 09:50
by vboctor
Obviously generating <br /> is wrong. Is the correct behaviour to generate a new line in the out (i.e. in the middle of a cell value)?

Can you test this and see if Excel can import it successfully (i.e. by editing the csv file manually before importing it in Excel.

Please report this issue in the bugtracker.

Regards,
Victor
MantisConnect
http://www.futureware.biz/mantisconnect/

Posted: 21 Mar 2006, 10:00
by vboctor
Oppss!!! I didn't notice the the bug is in the code above. There is nothing to report then except a feature request + a link to this thread.

Try the code below:

In csv_export.php:

Replace:

Code: Select all

    $t_function = 'csv_format_' . $t_column;
    echo $t_function( $t_row[ $t_column ] );
With:

Code: Select all

$t_function = 'csv_format_' . $t_column; 

# patch start 
if ( $t_column === 'description' ) 
{ 
    $t_bug_id = $t_row ['id' ];
    $t_description = bug_get_field( $t_bug_id, 'description' );
    echo csv_escape_string( $t_description ); 
} 
else 
{ 
    echo $t_function( $t_row[ $t_column ] ); 
} 

# patch end 

Posted: 21 Mar 2006, 17:59
by webwesen
after vboctor's patch I get:

Code: Select all

<p style="color:red">APPLICATION WARNING #403: Database field 'description' not found.</p>
in cvs file in 'Description' column.

I am running 1.0.1
my ugly code above worked though...

Re: CSV export help

Posted: 26 Feb 2008, 12:51
by Harz_test
Went for the buggy code that is working:)
The other one gave also gave me the 403 error code, added steps_to_reproduce with out a hassle.

If you can only fill me in with what you meant with:
and have edited the resulting output in csv_format_description(), so no html is printed out (like &nbsp;)
Anyhow, allmost kicked Mantis out of the project I'm on because of lack of this feature :roll:

Thanks for the buggy code, just need a way to be able to allow hard coded returns.

Re: CSV export help

Posted: 26 Feb 2008, 16:50
by vboctor
By the way, I've checked in recently code that supports export 'description'. 'additional_information' and 'steps_to_reproduce' to the View Issues, Print Issues, CSV export, and Excel export. The columns to be included is now customizable through the user interface and can be specific for each user. Administrators can use the Manage pages to customize the global defaults and defaults per project. Users can use the My Account -> Manage Columns page to do the same. The user can select a different set of columns per project per format. Also multi-line fields are supported in all formats.

This work will be included in Mantis 1.2.0.

Re: CSV export help

Posted: 29 Feb 2008, 15:10
by shaitan
Excellent, is this change something that we can easily migrate into a 1.1.1 install? This is the #1 feature my users have been requesting.

Re: CSV export help

Posted: 29 Feb 2008, 17:51
by vboctor
Not easy but it is possible. This would take a couple of consulting hours. If interested, please contact me via the Contact Us page.

Re: CSV export help

Posted: 06 Aug 2009, 16:22
by eanmantis
Am currently on mantis version 1.1.8. It doesn't seem to have "My Account -> Manage Columns page".
May I know how to get the "Description" field into the CSV Export file for mantis vwe 1.1.8..
Have been searching for a solution today and also dig into the php files on servers.. :cry:
Thank in advance for any help render... :D

Re: CSV export help

Posted: 09 Aug 2009, 16:59
by Buga
This is a Mantis 1.2 feature