CSV export help

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
mantisuser
Posts: 1
Joined: 21 Mar 2005, 07:33

CSV export help

Post 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?
webwesen
Posts: 27
Joined: 09 Aug 2005, 20:44

Post 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.
webwesen
Posts: 27
Joined: 09 Aug 2005, 20:44

Post 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  )
ktang
Posts: 6
Joined: 17 Mar 2006, 11:20

Post 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
vboctor
Site Admin
Posts: 1293
Joined: 13 Feb 2005, 22:11
Location: Redmond, Washington
Contact:

Post 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/
vboctor
Site Admin
Posts: 1293
Joined: 13 Feb 2005, 22:11
Location: Redmond, Washington
Contact:

Post 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 
webwesen
Posts: 27
Joined: 09 Aug 2005, 20:44

Post 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...
Harz_test
Posts: 2
Joined: 26 Feb 2008, 10:22

Re: CSV export help

Post 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.
vboctor
Site Admin
Posts: 1293
Joined: 13 Feb 2005, 22:11
Location: Redmond, Washington
Contact:

Re: CSV export help

Post 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.
Migrate your MantisBT to the MantisHub Cloud
shaitan
Posts: 6
Joined: 18 Jun 2007, 19:43

Re: CSV export help

Post 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.
vboctor
Site Admin
Posts: 1293
Joined: 13 Feb 2005, 22:11
Location: Redmond, Washington
Contact:

Re: CSV export help

Post 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.
Migrate your MantisBT to the MantisHub Cloud
eanmantis
Posts: 1
Joined: 06 Aug 2009, 16:14

Re: CSV export help

Post 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
Buga
Posts: 74
Joined: 31 Mar 2008, 12:10

Re: CSV export help

Post by Buga »

This is a Mantis 1.2 feature
Post Reply