Full-width Japanese text sticks out of the border after using autoFitRows

There’s something I noticed while working with Aspose.Cells on Japanese text.
When using Worksheet.AutoFitRows() with half-width text (such as Romanji, Alphanumeric or Half-width Katakana), Aspose has no problem fitting the text within the cell.
But when using full-width text (either Hiragana or Katakana), column width is always smaller than actual cell width, which results in the text sticks out of the border. This happens on both cases when only full-width text is used or when both full-width and half-width are used. So this seems like an issue with AutoFitRows() fail to calculate column width with full-width text involved.
Hope to see some insights on this, thanks.

This is my current source code:

AutoFitterOptions options = new AutoFitterOptions();
options.setAutoFitMergedCells(true);
options.setOnlyAuto(true);
sheet.autoFitColumns(options);
sheet.autoFitRows(options);

I also tried using options.setDefaultEditLanguage(DefaultEditLanguage.CJK); but this doesn’t seem to fix this issue
Version used : Aspose.Cells for Java, ver22.8
evidence.zip (41.6 KB)

@m16vip123
We can reproduce the issue by testing it on the latest version v24.6 using sample files and the following sample code. Found that full width Japanese text sticks out of the border after using autoFitRows. Please refer to the attachment. result.zip (45.9 KB)

The sample code as follows:

String[] files = new String[] {
		"full_width (alphanumeric).xlsx",
		"full_width (katakana).xlsx",
		"both_type.xlsx",
		"full_width (hiragana).xlsx",
		"half_width (katakana).xlsx",
		"half_width (alphanumeric).xlsx"
};
for (String file : files)
{
	Workbook book = new Workbook(filePath + file);
	Worksheet sheet = book.getWorksheets().get(0);
	
	AutoFitterOptions options = new AutoFitterOptions();
	options.setAutoFitMergedCells(true);
	options.setOnlyAuto(true);
	sheet.autoFitColumns(options);
	sheet.autoFitRows(options);
	
	String newFile = file.substring(0, file.length() - 5) + "_out.xlsx";
	book.save(filePath + newFile);
}

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): CELLSJAVA-46038

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.

1 Like