2

I know that when generating html that needs to be viewed in Excel, if I want to ensure that <br> tags don't cause a new row to be generated, I can specify

<style><!--table br {mso-data-placement:same-cell;} --></style>

In the <head> section.

What do I need to do if I want the same behaviour for lists (i.e. for content inside of <ul> or <ol> sections to be contained in the same cell)?

ktharsis
  • 3,160
  • 1
  • 19
  • 30
sasfrog
  • 2,410
  • 1
  • 17
  • 28
  • 1
    NB: Don't put the styles in comments. – RoToRa Aug 25 '10 at 14:00
  • Copy the css, and change 'table br' to 'ul br' I would think. – Gerben Apr 16 '11 at 18:57
  • 3
    Somewhere a fuzzy bunny is beaten every time an MSO-object is used....There are rendering engines that will properly export Excel documents in a manner that's clean, proper, and native. My tool of choice is PHPExcel (http://phpexcel.codeplex.com/), but it's just one of several options – bpeterson76 May 23 '11 at 04:22

1 Answers1

2

As many of you probably know, you can output data (a report, for example) as an Excel file, simply by adding right content-type and content-disposition header:

Response.ContentType = “application/vnd.ms-excel“;

Response.AppendHeader(“content-disposition“, “inline; filename=report.xls“);

add into a stylesheet:

br {mso-data-placement:same-cell;}

Himanshu padia
  • 7,428
  • 1
  • 47
  • 45