user1047184
user1047184

Reputation: 1

Getting display text as ###### for some of the cell in excel after writing from Vb.net code

I am writting to an excel file from my vb code. The code goes as below

xlsheet3 = xlBook.Sheets.Add(After:=xlSheet)

With xlsheet3

.Columns(5).NumberFormat = "@"

.Cells(j + 1, 5) = someStringValue 'Here "j" is a row counter and this line is in a "for loop"  

end with

After writing to excel, most of the cells in excel are correct. But some of the cell's text comes as ####### however if I click on the cell, formula bar shows the correct result. I have tried giving single code before adding the text still that did not help.

Please help me in resolving this.

Thank you

Upvotes: 0

Views: 600

Answers (5)

Luenda
Luenda

Reputation: 11

If widening and wrapping text doesn't work and the format is set to text which allows display of only 255 characters, try changing the format to general.

Upvotes: 1

Himanshu A Jadav
Himanshu A Jadav

Reputation: 2306

There is not any issue with your code. You need to increase the width of the column or have to use word wrap. In excel if your value is not fully visible it shows it is "######".

Upvotes: 1

AakashM
AakashM

Reputation: 63378

This is simply what Excel does when the data in a column is too wide to be displayed in the current column width. Make the column slightly wider and you will see all your data.

To autosize the column so it is wide enough to display all its data, double click the column divider at the right edge of the column, in the header bar.

Upvotes: 0

ChrisF
ChrisF

Reputation: 137168

See https://superuser.com/questions/65556/excel-displays-for-long-text-whats-wrong for some common reasons why Excel displays "######" in cells.

Either the cell is too narrow to display the contents or the contents are over 256 characters.

Check what you're writing to the cell. If it's not too long then all you need to do is resize the column to fit the new contents.

Upvotes: 0

MADMap
MADMap

Reputation: 3192

This just indicates that the cell is too small for showing the result: make it wider.

Upvotes: 0

Related Questions