More AutoFit issues

Hi guys it’s been a few days.

The work you did on AutoFitColumn was great, sizes realy well with fonts from 8 to 20pt havn’t tested any higher than that, execelent work.

I now have a problem with AutoFitRow it appears to work fine for single line rows but if a row has the Wrap Text option set it gets all screwed up.

Here are the scenarios. (All scenarios have data with carrage returns in them)
1) Wrap Text option set, Cell merged horizontally (does not matter with how many)
AutoFitRow set height to 108. (way too long)
2) Wrap Text option set, Cell not merged.
AutoFitRow sets correct height for one line only.
AutoFitColumn sets the width for the data as if there were no carrage returns. In other words it’s as if the multi line data is all on one line (but it renders as wrapped text). The resulting width in my test was 196.71. (way way too wide)

There seems no solution to this and as I use a single text blob for my addressing info. I will need to break down the text and add it to a number of different rows, unless you can suggest another solution.

I still believe there should be a QuickFit option which uses the performance optomised option, and a PerfaceFit option which uses the GDI+ routines to provide a best quality solution where performance is not an issue.


1)Wrap text with cell merged
Acutally MS Excel’s AutoFitRow doesn’t take effect on merged cell. You can test it in Excel manually.

2.)Wrap text with cell not merged
I will check AutoFitRow issue. But AutoFitColumn works in same way as MS Excel.

Could you email me your template about your problem? Thanks.

Apologies for not getting back to you earlier, I have been really busy...

1) I know MS Excel does not work this way but was testing multiple options and mentioned it for reference, since it seems that you are setting the height. Is 108 and arbitrary number you picked or is it calculated in any way.

I'm doing some work on this tomorrow I'll email some documents to you then.
The project I'm working on is a B2B purchasing site, we have been demonstrating it for 4 weeks now and every single customer we have seen,( that's 100% of them), have not even baulked, at signing up for the sales system. I believe most of this is the ease of use provided by you excel component. Smile

Thank you.

I will make a further investigation for this autofit issue when I get your documents.

@ojo,
Aspose.Excel is discarded and no more active development is done for it. It is replaced by another better product Aspose.Cells which supports all the latest features available in different versions of MS Excel. This new product also supports auto fitting rows and columns as desmonstrated in the following sample code:

// 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 2nd row of the worksheet
worksheet.AutoFitRow(1);

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

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

You may follow below links for more details about searching text:
AutoFit Rows and Columns

You can download the latest version of this product here for trial version:
Aspose.Cells for .NET(Latest version)

You may download a runnable solution here for testing.