View Issue Details

IDProjectCategoryView StatusLast Update
0009505mantisbtcsvpublic2011-10-16 14:24
Reporternico95 Assigned Torombert  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionno change required 
Product Version1.1.1 
Summary0009505: How to Add the custom fields for the CSV export ?
Description

My question was: I have any customs fields in the projects and I would like to have these in the CSV export.

Remark, all the projects haven't the same customs fields ...

Additional Information

All the modifications I did are in the csv_export.php

1) a correction of a bug: send the correct header to the navigator (line 59)
//NPL
// header( 'Content-Type: text/plain; name=' . urlencode( $t_filename ) );
header( 'Content-type: text/csv' );
//-NPL

2) how to add the customs fields names on the first line (line 76)

foreach ( $t_columns as $t_column ) {
    if ( !$t_first_column ) {
        echo $t_sep;
    } else {
        $t_first_column = false;
    }

    if ( strpos( $t_column, 'custom_' ) === 0 ) {
        $t_column_title_function = 'print_column_title';
        helper_call_custom_function( $t_column_title_function, array( $t_column, COLUMNS_TARGET_CSV_PAGE ) );
    } else {
        $t_function = 'print_column_title_' . $t_column;
        $t_function( '', 'ASC', COLUMNS_TARGET_CSV_PAGE );
    }
}

//NPL Add of the customs fields names
$t_related_custom_field_ids = custom_field_get_linked_ids( $t_project_id );
foreach( $t_related_custom_field_ids as $t_id ) {
if ( !$t_first_column ) {
echo $t_sep;
} else {
$t_first_column = false;
}
$t_def = custom_field_get_definition( $t_id );
echo string_display( lang_get_defaulted( $t_def['name'] ) );
}
//-NPL

echo $t_nl;

3) how to add the customs fields values for each bug (at the end)
//NPL Ajout des champs personnalisés
$t_related_custom_field_ids = custom_field_get_linked_ids( $t_project_id );
foreach( $t_related_custom_field_ids as $t_id ) {
if ( !$t_first_column ) {
echo $t_sep;
} else {
$t_first_column = false;
}
$t_def = custom_field_get_definition( $t_id );
print_custom_field_value( $t_def, $t_id, $t_row['id'] );
}
//-NPL

    echo $t_nl;
TagsNo tags attached.

Relationships

related to 0013370 closedrombert CSV export specifies incorrect MIME type 

Activities

nico95

nico95

2008-08-08 09:53

reporter   ~0019096

Update for the 1)

1) a correction of a bug: send the correct header to the navigator (line 59)
//NPL
// header( 'Content-Type: text/plain; name=' . urlencode( $t_filename ) );
header( 'Content-type: text/csv; name=' . urlencode( $t_filename )' );
//-NPL

vboctor

vboctor

2008-08-10 01:44

manager   ~0019099

Adding custom fields to View Issues, Print Issues, CSV and Excel exports is now supported via the web interface in 1.2.x.

Just a question, what is the effect of changing text/plain to text/csv. I don't think we have this applied. I wonder if this is just about using a more accurate mime type, or does the browser behave differently.

nico95

nico95

2008-08-15 04:53

reporter   ~0019163

Open with excel a csv file with the header text/plain has for effect to put only in column A for each lines.
With text/csv, Excel interpret each lines with the current separator (; for me).
So each columns are with the correct value.

Tested with FF3.0.1

nico95

nico95

2008-08-15 06:25

reporter   ~0019165

For the adding custom fields in version 1.2.x, it is possible for all fields like my modification,, or for a pre-defined list ?

rombert

rombert

2011-10-05 19:01

reporter   ~0029917

Fix applied already as part of 0013370