Creating an Excel file from ASP and setting a LineFeed

Discussion in 'ASP General' started by Michael G. Schneider, Oct 21, 2005.

  1. From ASP I create response, which is to be shown as an Excel worksheet in
    the user's browser (by setting the ContentType and creating a table). This
    works fine.

    Does anybody know what to do, if one of the cells should contain a multiline
    text? I already tried by inserting a <br> inside the <td>. But this won't
    work.

    --
    Michael G. Schneider
    MTLookup http://www.mtlookup.com
    Movable Type Weblog http://www.movable-type-weblog.com/
    Michael G. Schneider, Oct 21, 2005
    #1
    1. Advertising

  2. Michael G. Schneider wrote:
    > From ASP I create response, which is to be shown as an Excel
    > worksheet in the user's browser (by setting the ContentType and
    > creating a table). This works fine.
    >
    > Does anybody know what to do, if one of the cells should contain a
    > multiline text? I already tried by inserting a <br> inside the <td>.
    > But this won't work.


    Reverse engineer it. Create a spreadsheet in excel that contains multiline
    data, save it as html and look at the source to see what you need to
    generate in asp.

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Oct 21, 2005
    #2
    1. Advertising

  3. "Bob Barrows [MVP]" <> schrieb im Newsbeitrag
    news:...

    > Reverse engineer it. Create a spreadsheet in excel that contains multiline
    > data, save it as html and look at the source to see what you need to
    > generate in asp.


    Thank's a lot for the answer.

    Currently, I only set the ContentType corretly, then generate a simple HTML
    table with nothing more than some tr's and td's. That is enough for making
    Excel show the worksheet.

    Reverse engineering the Excel HTML output meant that a lot of "noise" would
    have to be generated. There is much more in a HTML file generated by Excel
    than the HTML table.

    I hoped that there would be some simple mechansim, such as inserted a <br>
    or a vbCr or a vbLF or a vbCrLF or something else, which does the trick.

    --
    Michael G. Schneider
    MTLookup http://www.mtlookup.com
    Movable Type Weblog http://www.movable-type-weblog.com/
    Michael G. Schneider, Oct 21, 2005
    #3
  4. Michael G. Schneider wrote:
    > "Bob Barrows [MVP]" <> schrieb im Newsbeitrag
    > news:...
    >
    >> Reverse engineer it. Create a spreadsheet in excel that contains
    >> multiline data, save it as html and look at the source to see what
    >> you need to generate in asp.

    >
    > Thank's a lot for the answer.
    >
    > Currently, I only set the ContentType corretly, then generate a
    > simple HTML table with nothing more than some tr's and td's. That is
    > enough for making Excel show the worksheet.
    >
    > Reverse engineering the Excel HTML output meant that a lot of "noise"
    > would have to be generated. There is much more in a HTML file
    > generated by Excel than the HTML table.


    I'm not telling you to use the entire html from the test file ... just find
    the part where the line break is accomplished and incorporate that into your
    asp code.

    I suspect it has something to do with setting the column width (perhaps
    using <col> tags). The only way to know for sure is to look at the html that
    Excel generates to accomplish the same formatting.

    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Oct 21, 2005
    #4
  5. Michael G. Schneider

    McKirahan Guest

    "Michael G. Schneider" <> wrote in
    message news:O#...
    > "Bob Barrows [MVP]" <> schrieb im Newsbeitrag
    > news:...
    >
    > > Reverse engineer it. Create a spreadsheet in excel that contains

    multiline
    > > data, save it as html and look at the source to see what you need to
    > > generate in asp.

    >
    > Thank's a lot for the answer.
    >
    > Currently, I only set the ContentType corretly, then generate a simple

    HTML
    > table with nothing more than some tr's and td's. That is enough for making
    > Excel show the worksheet.
    >
    > Reverse engineering the Excel HTML output meant that a lot of "noise"

    would
    > have to be generated. There is much more in a HTML file generated by Excel
    > than the HTML table.
    >
    > I hoped that there would be some simple mechansim, such as inserted a <br>
    > or a vbCr or a vbLF or a vbCrLF or something else, which does the trick.


    [snip]

    Bob's suggestion of reverse engineering meant to find the small difference
    generated to support multiline data by looking at the HTML output.

    My efforts identified this style: { white-space:normal }

    What happens when you try this: <td style="white-space:normal">
    McKirahan, Oct 21, 2005
    #5
  6. "McKirahan" <> schrieb im Newsbeitrag
    news:...

    > Bob's suggestion of reverse engineering meant to find the small difference
    > generated to support multiline data by looking at the HTML output.
    >
    > My efforts identified this style: { white-space:normal }
    >
    > What happens when you try this: <td style="white-space:normal">


    Thank's a lot for the answer. I can confirm that it has something to do with
    this style. However, it is not this style alone. For example, if the
    following is opened by MS Excel...

    <table>
    <tr>
    <td style="white-space:normal;">1<br>2<br>3<br>4</td>
    </tr>
    </table>

    ....four rows will be filled with the numbers.

    I think it is best, if I switch over to generating a file that contains all
    those Excel specific style information. Then it will work. Finding exactly
    which minimum combination of CSS is necessary is probably not worth the
    effort.

    Thank's again.

    --
    Michael G. Schneider
    MTLookup http://www.mtlookup.com
    Movable Type Weblog http://www.movable-type-weblog.com/
    Michael G. Schneider, Oct 21, 2005
    #6
  7. Michael G. Schneider

    Larry Bud Guest

    Michael G. Schneider wrote:
    > "McKirahan" <> schrieb im Newsbeitrag
    > news:...
    >
    > > Bob's suggestion of reverse engineering meant to find the small difference
    > > generated to support multiline data by looking at the HTML output.
    > >
    > > My efforts identified this style: { white-space:normal }
    > >
    > > What happens when you try this: <td style="white-space:normal">

    >
    > Thank's a lot for the answer. I can confirm that it has something to do with
    > this style. However, it is not this style alone. For example, if the
    > following is opened by MS Excel...
    >
    > <table>
    > <tr>
    > <td style="white-space:normal;">1<br>2<br>3<br>4</td>
    > </tr>
    > </table>
    >
    > ...four rows will be filled with the numbers.
    >
    > I think it is best, if I switch over to generating a file that contains all
    > those Excel specific style information. Then it will work. Finding exactly
    > which minimum combination of CSS is necessary is probably not worth the
    > effort.


    Here's the style I use for wrapping text with possible <BR> breaks.

    ..text {mso-number-format:General; text-align:general;white-space:
    normal;mso-spacerun: yes }
    Larry Bud, Oct 21, 2005
    #7
  8. "Larry Bud" <> schrieb im Newsbeitrag
    news:...

    > Here's the style I use for wrapping text with possible <BR> breaks.
    >
    > .text {mso-number-format:General; text-align:general;white-space:
    > normal;mso-spacerun: yes }


    Thank's a lot for the answer. This does work.

    Does anybody know, whether these style are documented somewhere? Is there a
    list, which attributes / values are allowed? Or does anybody know a way for
    autosizing the column width?

    --
    Michael G. Schneider
    MTLookup http://www.mtlookup.com
    Movable Type Weblog http://www.movable-type-weblog.com/
    Michael G. Schneider, Oct 22, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sck10
    Replies:
    1
    Views:
    1,919
    Steven Cheng[MSFT]
    Mar 23, 2006
  2. Frogleg

    <div> withut linefeed?

    Frogleg, Jul 31, 2005, in forum: HTML
    Replies:
    7
    Views:
    1,052
    Toby Inkster
    Jul 31, 2005
  3. Johannes Busse

    xsl:message without linefeed?

    Johannes Busse, Dec 7, 2004, in forum: XML
    Replies:
    4
    Views:
    1,083
    Johannes Busse
    Dec 8, 2004
  4. Matthias

    Linefeed in xsl:fo with FOP

    Matthias, Aug 8, 2006, in forum: XML
    Replies:
    0
    Views:
    881
    Matthias
    Aug 8, 2006
  5. guycasome
    Replies:
    1
    Views:
    350
    guycasome
    Aug 24, 2007
Loading...

Share This Page