Excel AutoFitRow()

Hi,

I am having a problem with the autofit row. Basically a cell contains long text and I want the cell to be text wrapped and also row fit. However when I look at the Excel sheet, the text are wrapped but the row is not auto fit (actually some are some are not). Here is my code:

'do post formatting
Dim i, j As Integer

For i = 3 To x 'x is the total # of rows populated with data

For j = 0 To CELL_COUNT

ws.Cells(i, j).Style.IsTextWrapped = True

Next

ws.AutoFitRow(i)

Next

I populate all the cell with text before executing this code blockā€¦

Thanks!
C.

Could you please send your file to excel@aspose.com? I will check it.

@clchris,
Aspose.Excel is discarded and no more available now. It is replaced with an advanced product Aspose.Cells that contains a lot of features to process rows and columns in a worksheet. Here is an example that demonstrates the AutoFitRow feature using this new product:

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

string InputPath = dataDir + "Book1.xlsx";

// Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream(InputPath, FileMode.Open);

// Opening the Excel file through the file stream
Workbook workbook = new Workbook(fstream);

// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];

// Auto-fitting the 3rd row of the worksheet
worksheet.AutoFitRow(1, 0, 5);

// Saving the modified Excel file
workbook.Save(dataDir  + "output.xlsx");

// Closing the file stream to free all resources
fstream.Close();

Follow the below link for more information on auto fitting rows and columns:
AutoFit Rows and Columns

The link to download the latest version is given below:
Aspose.Cells for .NET(Latest version)

You may download a runnable solution here for testing different functions of this new product.