AutoFit Row Height Bug

Laurence,

I’ve attached my project. Just run it and you’ll see that the line feeds appear in the Excel spreadsheet but the autofit row height is not working. Also, in Excel 2000 the line feeds appear as squares.

Thanks,
Natan

For autofit issue, please set cell.Style.IsTextWrapped to true.

For line feeds appear as squares issue:

In MS Excel, line feed character is ASCII code 10. If you add ASCII code 13 in line feed, in some version of MS Excel will will show a square.

Laurence,

Add the following line of code right above the Select Case statement in the subWriteCellValue() method:

exlCell.Style.IsTextWrapped = True

Now the row height is adjusting but not enough to fit the contents of the cell. Notice that the “Vins” is missing from row 1 and “Victuailles” from row 4.

Thanks,
Natan

Hi Natan,

AutoFitRow is not a very accurate method, especially the column width is narrow. I plan to optimize it in the next 1-2 weeks.

By the way, in your program, you use cell.Style property to access all cells' formattings. That will consume a lot of memory because when you use cell.Style property to access a cell's formattings, a new Style object is created.

If you don't set the style at run time, please set them to nothing after you access them:

Select Case exlCell.Style.Number
...

End Select

exlCell.Style = nothing

If you have to set the style at run time, please create a Style object and assign it to cells with same formattings. Please check Format Routines.