This is a migrated thread and some comments may be shown as answers.

Background Color to CSV Header

1 Answer 864 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amol
Top achievements
Rank 2
Amol asked on 11 Dec 2009, 11:38 AM
Hi Telerik Team,

I had created a application which will export RAD Grid to CSV File. however i cannot export data with proper formatting which i have given to Grid. My requirement is set the background color of Header to Red. It is properly working if i export data to Excel Sheet. how ever my requirement is export data to CSV with proper Formatting

Here is what i have used

         rgExport.DataSource = timesheetList;
                rgExport.DataBind();
                rgExport.ExportSettings.FileName = NextJobPLConstants.TIMESHEET_EXPORT_FILE;

                
                rgExport.ExportSettings.ExportOnlyData = true;
                rgExport.ExportSettings.IgnorePaging = true;
                rgExport.ExportSettings.OpenInNewWindow = true;
                rgExport.MasterTableView.ExportToCSV();
                rgExport.Rebind();



protected void rgExport_ItemCreated(object sender, GridItemEventArgs e)
    {

     


        if (e.Item is GridHeaderItem)
        {
            GridHeaderItem headerItem = (GridHeaderItem)e.Item;
            headerItem.Style["font-size"] = "12px";
            headerItem.Style["font-style"] = "Verdana";
            headerItem.Style["color"] = "black";
            headerItem.Style["background-color"] = "#99CC00";
            headerItem.Style["border-width"] = "1";
            headerItem.Style["border-style"] = "Solid";
            headerItem.Style["border-color"] = "black";
            headerItem.Style["height"] = "50px";
            headerItem.Style["vertical-align"] = "bottom";
            headerItem.Style["horizontal-align"] = "center";
            foreach (TableCell cell in headerItem.Cells)
            {
                cell.Style["text-align"] = "center";
                cell.Style["font-weight"] = "bold";

            }
        }

        if (e.Item is GridDataItem)
        {
            GridDataItem dataItem = (GridDataItem)e.Item;
            dataItem.Style["background-color"] = "#CCFFFF";
            dataItem.Style["border-width"] = "1";
            dataItem.Style["border-style"] = "Solid";
            dataItem.Style["border-color"] = "black";
            dataItem.Style["font-style"] = "Verdana";

        }
        
    }

Please help me in this matter.

Thanks,

Amol




1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 11 Dec 2009, 12:04 PM
Hello Amol,

CSV is a plain text format that doesn't support any styles/formatting. Please examine the following link for more information:

http://en.wikipedia.org/wiki/Comma-separated_values


Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Amol
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Share this question
or