converting to excel and column data with carriage returns

B

Bernie Yaeger

I'm using the following function (I'm displaying the guts of it only) to
convert a datatable to an excel spreadsheet:

For Each mrow In dt.Rows
rowindex += 1

colindex = 0

For Each col In dt.Columns

colindex += 1

objws.Cells(rowindex, colindex) = mrow(col.ColumnName).ToString()

Next

Next

It works fine; however, when I convert columns with carriage returns in
them, the row does not wrap inside Excel; instead, you end up with a very
long (verticle) column. Inside Excel, even columns/autofit selection has
not effect. The entire spreadsheet, therefore, looks distorted. Is there
any way to strip out chr(10) + chr(13) from the data?

Thanks for any help.

Bernie Yaeger
 
C

Cor

Hi Bernie,

When you look down about 20 rows in this newgroup you see a question from
Able almost like this,

I found it funny because a lot of people where answering on that.

Armin gives as extra the answer you need complete. (with the vbcrlf)
(I would take that one, mine was just a completely alternative method from
the earlier posters and I posted the same time as Armin)

If you cannot find it, I can give you of course the answer, but there are so
much possibilities in this message and answers.

By the way, if it is than still not working have than also a look at the
"HT" "09" and "Lf" "13" because as far as I remember me, Cindy once told in
this newsgroup that that was used with Excel.

I hope this works.

Cor
 
B

Bernie Yaeger

Hi Cor,

I've looked 60 down and in different sort orders but can find no other
question like mine. Can you give me some more info on that message?

Tx,

Bernie
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top