473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Creating an Excel file from ASP and setting a LineFeed

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/
Oct 21 '05 #1
7 1942
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"
Oct 21 '05 #2
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> schrieb im Newsbeitrag
news:Ox*************@TK2MSFTNGP10.phx.gbl...
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/
Oct 21 '05 #3
Michael G. Schneider wrote:
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> schrieb im Newsbeitrag
news:Ox*************@TK2MSFTNGP10.phx.gbl...
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.
Oct 21 '05 #4
"Michael G. Schneider" <mg**********@movable-type-weblog.com> wrote in
message news:O#**************@TK2MSFTNGP09.phx.gbl...
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> schrieb im Newsbeitrag
news:Ox*************@TK2MSFTNGP10.phx.gbl...
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">
Oct 21 '05 #5
"McKirahan" <Ne**@McKirahan.com> schrieb im Newsbeitrag
news:Re********************@comcast.com...
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/
Oct 21 '05 #6

Michael G. Schneider wrote:
"McKirahan" <Ne**@McKirahan.com> schrieb im Newsbeitrag
news:Re********************@comcast.com...
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 }

Oct 21 '05 #7
"Larry Bud" <la**********@yahoo.com> schrieb im Newsbeitrag
news:11*********************@g44g2000cwa.googlegro ups.com...
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/
Oct 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jeremy Langworthy | last post by:
Hi I am trying to create a MS Excel format CSV but I can't figure out how to get the line feed/carriage return/new record working properly. I am nding each line/record with these characters:...
17
by: Guyon Morée | last post by:
what is the difference? if I open a text file in binary (rb) mode, it doesn't matter... the read() output is the same.
2
by: brazilnut52 | last post by:
I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better I have created a simple COM DLL in .NET by using the COM class...
2
by: Bryan Harrington | last post by:
Hello all.. I'm working on some reports, and have added the ability to "download" the reports to excel. Not a big deal, fairly straight forward. However, PHB wants to be able to create some pivot...
9
by: Paul | last post by:
Hi all Arggghhh........... The problem.....I want the user to be able to create an excel document and name particular cells in the document where they want the data to be placed and then save...
14
by: Raoul Snyman | last post by:
Hi, I need to be able to programatically create excel spreadsheets in ASP.NET (C#), WITHOUT having MS Office on the server. Does anybody have any advice/links/whatever for me? Thanks in...
9
by: wscrsurfdude | last post by:
f = open('myfile,'r') a = f.read(5000) When I do this I get the first 634 bytes. I tried using the: f = open('myfile,'rb') option, but now there are a few 0x0D bytes extra in myfile. 0x0D =...
9
by: Doug Glancy | last post by:
I got the following code from Francesco Balena's site, for disposing of Com objects: Sub SetNothing(Of T)(ByRef obj As T) ' Dispose of the object if possible If obj IsNot Nothing AndAlso...
2
by: felciano | last post by:
Hi -- Is there a standard way to use the csv module to export data that contains multi-line values to Excel? I can get it mostly working, but Excel seems to have difficulty displaying the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.