Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am using below code for export to excel for simple html table(not using gridview or any other reporting panel or control,it is simple html table).

C#
public void ExportToExcel(ref string html, string fileName)
{
    html = html.Replace(">", ">");
    html = html.Replace("&lt;", "<");

    HttpContext.Current.Response.ClearContent();
    HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + fileName + "_" + DateTime.Now.ToString("M_dd_yyyy_H_M_s") + ".xls");
    HttpContext.Current.Response.ContentType = "application/xls";
    HttpContext.Current.Response.Write(html);
    HttpContext.Current.Response.End();
}


Issue:

i am applying css property of text-transform on username to capitalize it. it is showing proper titlecase on web. but when i export my html table to excel.it is showing lowercase username.
like

CSS
.titlecase{
 text-transform:capitalize;
}

example td:
<td class="titlecase"> kethrine </td>
Need Solution for:
I need solution which helps that
when i export my html table to excel , my text-trasform:capitalize property should be applied and my text should be in title case in excel.

i can explain more in case of any concern.


Thank you in advance.
Posted
Updated 28-Sep-15 5:40am
v6
Comments
F-ES Sitecore 28-Sep-15 11:47am    
Excel will be ignoring your styles, it is a spreadsheet application, it doesn't understand css. You'll need to make sure the username is capitalised in the html you're passing in. We don't know how that is generated so it's hard to give specific advice.
ramyajaya 28-Sep-15 15:13pm    
The general working of content type is that the html tags are converted into fields instead of generating td with title case class you can use th tag which will do the needful.

Because td tag mean to generate column but it will not refer to any class and apply style but in html if you use tag it would have made bold

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900