Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
using multiple mso-number-format's when exporting using HttpResponse
Hi,
I've got the following code to write out a grid to Excel: private void WriteExcelDataToHttpResponse() { Response.Clear(); Response.Charset = ""; Response.Buffer = true; Response.ContentType = "application/vnd.ms-excel"; System.IO.StringWriter stwWriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htwHtmlTextWriter = new System.Web.UI.HtmlTextWriter(stwWriter); this.ExcelTable.RenderControl(htwHtmlTextWriter); string s_styleInfo = @"<style td { mso-number-format:""" + "\\@" + @"""; } </style"; string s_excel = stwWriter.ToString(); Response.Write(s_styleInfo + s_excel); Response.End(); } This results in the following in the output file that works perfectly: ..xl24 {mso-style-parent:style0; mso-number-format:"\@"; white-space:normal;} Now, every "td" uses this class, like so: <td class=xl24 width=138 style='width:104pt'SocialSecurityNumber</td I've got something like this to add date to the table prior to exporting it: row = new HtmlTableRow(); // name column cell = new HtmlTableCell(); cell.InnerText = HttpUtility.HtmlEncode(s.Name); row.Cells.Add(cell); ExcelTable.Rows.Add(row); My question is, can I specify a different mso-number-format in specific cells in this code? If so, how? E.g. cell.something = "mso-number-format:0"; Many thanks! Mark |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Exporting multiple sheets to multiple htm files? | Excel Discussion (Misc queries) | |||
Exporting from Excel to multiple XML files | Excel Discussion (Misc queries) | |||
Exporting To Excel With ASP - Number Problem | Excel Programming | |||
Exporting multiple worksheets as CSV | Excel Programming | |||
Exporting multiple worksheets as CSV | Excel Programming |