Observe column K in the source excel file, upon passing the sheet through AutoFitColumns function the column width becomes extremely small (observe the output file).
I have attached the code, source excel file and the output excel . AutoFitColumns should ensure that the column width is adjusted according to the data in the cells but in this case the width drastically decreases and effects the visibility of data in column. Please suggest a fix, FYI aspose cells version is 25.5.
using Aspose.Cells;
namespace columnwidth
{
internal class Program
{
static void Main(string[] args)
{
string sourcePath = ""; //enter source file path here
Workbook sourceWb = new Workbook(sourcePath);
Worksheet sourceSheet = sourceWb.Worksheets[0];
AutoFitterOptions autoFitOptions = new AutoFitterOptions();
autoFitOptions.IgnoreHidden = true;
autoFitOptions.AutoFitMergedCellsType = AutoFitMergedCellsType.EachLine;
sourceWb.Worksheets[0].AutoFitColumns(4, 8, 40, 8, autoFitOptions);
string outputPath = ""; //enter output path here
sourceWb.Save(outputPath);
}
}
}
@Rit3sh
Thank you for providing the sample code, source file, and the output file. We appreciate the detailed information, as it allowed us to quickly set up a reproduction environment to investigate the behavior you are seeing with the AutoFitColumns method.
I have successfully reproduced the issue using Aspose.Cells for .NET 25.5. Upon running your code, I observed that Column K is indeed being resized to an extremely small width, which causes the data to become hidden or truncated. This appears to be a calculation discrepancy in the auto-fit engine when processing the specific content or formatting present in that column.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-60007
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
i got this issue after upgrading aspose cells version from 17.12 to 25.5, i observed that if i switch aspose cells version to 17.12 and replace the line autoFitOptions.AutoFitMergedCellsType = AutoFitMergedCellsType.EachLine; with autoFitOptions.AutoFitMergedCells = true; the width of column K is displaying correctly.
Thank you for providing these additional details regarding the version regression and the specific behavior of the AutoFitMergedCellsType property.
The observation that the issue emerged after upgrading from version 17.12 and is tied to the transition from the legacy AutoFitMergedCells property to the newer AutoFitMergedCellsType.EachLine setting is very helpful. This distinction provides valuable context for our development team to narrow down the cause of the width calculation discrepancy in column K.
I have updated the internal investigation record with your findings. We will continue to analyze the differences in how these options handle merged cell dimensions in the latest version to ensure the behavior is corrected.
We will notify you here as soon as there are any updates or a fix becomes available.
The issue is currently being investigated by our development team. We are analyzing the internal logic of the column width calculation to determine why the behavior changed in the recent version.
Regarding an ETA, we generally do not provide specific dates for bug fixes as the timeline depends on the complexity of the issue and the results of our quality assurance testing. However, we will notify you here as soon as a fix or a formal update is available.
In the meantime, we recommend using the workaround provided previously if it meets your requirements.
Moreover, we will check if we can provide you with an ETA regarding your issue. Generally, simple issues are resolved within a week or two, while complex issues may take a few weeks or even months to fix. We will keep you updated soon.
We are pleased to inform you that your issue (Ticket ID: CELLSNET-60007) has been resolved. As this was identified as a regression issue, we prioritized its resolution promptly. The fix/enhancement is scheduled to be included in the upcoming Aspose.Cells v26.4 release, anticipated in the first half of April 2026. We will notify you immediately once the new version becomes available.
Ok,
FYI if we remove the line autoFitOptions.AutoFitMergedCellsType = AutoFitMergedCellsType.EachLine; the width of column K is displayed correctly , what can be the general repercussions of removing this line, for different lengths of data and column widths, not just in this case, will it cause some unexpected behavior?
@Rit3sh
We have fixed this issue.
AutoFitMergedCellsType.EachLine will only work when merged area is completely included in in the area that requires auto fit
The issues you have found earlier (filed as CELLSNET-60007) have been fixed in this update. This message was posted using Bugs notification tool by leoluo