We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

AutoFitRow in Aspose.Excel version 1.9.1.1

Dose AutoFitRow works in the latest version ?

In my excel file, Cell A1 has Text Control “Wrap Text” activated.

I use this code to put value and use AutoFitRow


Dim myExcel As Aspose.Excel.Excel
myExcel = New Aspose.Excel.Excel
myExcel.Open(“c:\temp\nima.xls”)

Dim tmp As String = “Hi” & vbNewLine & “Today is” & vbNewLine & “Monday” & vbNewLine & "Bye"
tmp = Replace(tmp, vbNewLine, Chr(10), 1, -1, vbTextCompare)
tmp = Replace(tmp, Chr(13), Chr(10), 1, -1, vbTextCompare)

myExcel.Worksheets(“Sheet1”).Cells(“A1”).PutValue(tmp)
myExcel.Worksheets(“Sheet1”).AutoFitRow(1)


However in my excel file, Row 1 has’nt change the row size.
I tried also with

myExcel.Worksheets(“Sheet1”).AutoFitRow(0)

But without any result.

Cell A1 is a merged cell, right? In MS Excel, autofit doesn’t take effect on merged cells, so is Aspose.Excel.

Hi

No

Cell A1 is not a merged cell.
The only properties I have in this cell is that I have activated “Wrap text”

Hi nima,

Please download the latest hotfix and have a try.

Hi

Still some problem.
How do you calculate Row Height ?

When I have 4 row in my cell, Autofitrow method change the cell height to fit for 2 rows.

What’s the string in your cell? Could you post it here?

And if possible, could you send the file to me?

Thanks.

Hi

I am using Aspose.Excel Version 1.9.1.3

here is the code that I use :


Dim myExcel As Aspose.Excel.Excel, mySheet As Aspose.Excel.Worksheet

myExcel = New Aspose.Excel.Excel
myExcel.Open("…\nima.xls")
mySheet = myExcel.Worksheets(“Sheet1”)

Dim tmp As String = “hej” & vbNewLine & “har” & vbNewLine & “mar” & vbNewLine & “du”
tmp = Replace(tmp, vbNewLine, Chr(10), 1, -1, vbTextCompare)
tmp = Replace(tmp, Chr(13), Chr(10), 1, -1, vbTextCompare)

mySheet.Cells(“A1”).PutValue(tmp)
mySheet.AutoFitRow(mySheet.Cells().CreateRange(“A1”,“A1”).FirstRow)

myExcel.Save("…\nima2.xls",Aspose.Excel.FileFormatType.Default)


I will send nima.xls and nima2.xls via email to you

Hi nima,

I got your file and found the problem. It will be fixed before the end of April. Now thanks for your patience.

Any hotfix about this bug ?

Hi nima,

Sorry for the delay. I am working on this issue but it’s really a complex problem. So you have to wait for another one week. Thanks for your patience.

@nima,
Aspose.Excel is discontinued and no more under development. We have introduced a new product Aspose.Cells which covers all the features supported by legacy and latest spread sheets. You can auto fit rows and columns using this new product as well as shown in the following code snippet.

// Instantiating a Workbook object
Workbook workbook = new Workbook(dataDir + "book1.xls");

// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.getWorksheets().get(0);

// Auto-fitting the 2nd row of the worksheet
worksheet.autoFitRow(1);

// Auto-fitting the 1st column of the worksheet
worksheet.autoFitColumn(0);

// Saving the modified Excel file in default (that is Excel 2003) format
workbook.save(dataDir + "AutoFitRowsandColumns_out.xls");

// Print message
System.out.println("Row and Column auto fit successfully."); 

For further details about auto fitting the rows and columns using this new product, you may visit the following link:
Autofit Rows and Columns

Latest version can be downloaded here for testing:
Aspose.Cells for .NET (Latest Version)

A complete solution containing hundreds of ready to run examples along with all the required template files can be downloaded here to test variety of features.