Auomatically sizing the height of a row dependnt on the amount of data conatained within?

Hi there,

Im trying to basically ‘autosize’ the height of the row dependant on the daa contained within. Does anyone know how I can achive this?

THanks for your time,

Adam Smith

IS Developer Barnfield College

Dear Adam,

Please try Worksheet.AutoFitRow method.

Am I missing something? That seems to have no affect on the height of the row... I have used both methods but neither resize at all.

Thanks for your reply,

Adam Smith<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Could you please post your file and sample code? I will check this issue ASAP. Maybe there are some hidden worksheets in your template file.

Hi there,

Sorry about the late reply. <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />Holiday and all that.

The code is: -
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

With xlsExcel.Worksheets(0)
.Cells("A89").PutValue("DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA ")
.Cells("A89").Style.IsTextWrapped = True
.AutoFitRow("89")
End With

Thats just snippet of the code but that is the way I am using it.

I just can’t work it out but it is integral to my design.

Thanks for your help,

Adam

And there is the excel spreadsheet

Hi Adam,

AutoFit row doesn’t work on merged cells. That’s same as MS Excel. You can test it in MS Excel.

Ah ok… so if i
put the information into a single unmerged cell
autosize the cell
wrap the information?

I know this may leave a big space at the bottom but its all I can think of…

Thas a bit rubbish on microsofts behalf really… Hmm back to the drawing board.

Thanks for your help,

Adam Smith

You can try to autofit an unmerged cell then merge the cell.

@KGRMNH,
Aspose.Excel is discontinued and no more available now. It is replaced by Aspose.Cells that contains lot of features to work with rows and columns along with all the other advanced features supported by different versions of MS Excel. You can achieve your current requirement using this new product as follows:

Workbook workbook = new Workbook();
workbook.Worksheets[0].Cells["A1"].Value = "DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA";
workbook.Worksheets[0].Cells["A2"].Value = "DATA DATA DATA DATA DATA";
workbook.Worksheets[0].Cells["A3"].Value = "DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA";
workbook.Worksheets[0].Cells["A4"].Value = "DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA";

StyleFlag styleFlag = new StyleFlag();
styleFlag.All = true;
Style style = workbook.Worksheets[0].Cells["A1"].GetStyle();
style.IsTextWrapped = true;
workbook.Worksheets[0].Cells.Columns[0].ApplyStyle(style, styleFlag);
workbook.Worksheets[0].Cells.SetColumnWidthPixel(0,200);
workbook.Worksheets[0].AutoFitRows();
workbook.Save("WrappedCell.xlsx");

For more information about working with Rows and Columns refer to the following article:
Rows and Columns

To run this sample code download the latest version of Aspose.Cells for .NET here:
Aspose.Cells for .NET (Latest Version)

You can test different features of this new product by downloading an executable solution here.