Hi,
I tried this with aspose 20.6.
I am trying to autofit a excel sheet which has merged cells in one sheet and unmerged regular cells in another sheet.
I do specify fixed column widths and row heights.
column widths are depending upon the column - like in attached excel - “Name” column is 20
But, row height in both sheets is always 12 for each row.
Autofitting is happening, but its having some mixed behavior which I have some concerns on.
I use Tahoma size 8 throughout my excel.
PROBLEM 1:
If I autofit it (whether the value is bolded or unbolded -2 the row height comes to 10.5 always when the values can fit in one line - however at times even when it fits in one line, it increases the height slightly. I have attached a sample file. Please see the “Sample Data” sheet - row 8 - “Rhode Island Springs”).
PLEASE NOTE: my column widths you see are to remain fixed and so I fix it using the setColumnWidth methods of aspose - THEY ARE FIXED BY NEED . So, “Name” column in “Sample Data” sheet should be 20 only. It is not allowed to change based on project need.
PROBLEM 2:
For merged cells I use the following code:
AutoFitterOptions options = new AutoFitterOptions();
-
options.setAutoFitMergedCells(true);*
-
try *
-
{*
-
worksheet.autoFitRows(options);*
-
} *
-
catch (Exception ex) *
-
{*
-
getLogger().error("Autofit rows error : "+ex);*
-
}*
If you see in attached sample file - sheet “Metadata” - Row 1 - containing value - “Sample Data” value - it gets 10.50 height - I expect this to be normal because when I use regular aspose autofit (not Autofitter) in “Sample Data” sheet I get 10.5.
But, the subsequent row “Row 2” - containing value “Sample Stream” gets row height 11.25. There are a merged cells on that entire row. So, it should not be an issue that it expanded slightly.
However,if I take to excel select in excel the entire content and autofit - the 11.25 becomes 10.5. This is what confuses me. Aspose gives it 11.25 for some rows and not all and when I autofit the excel in MS Excel, it further autofits. Its as if the autofit done in aspose is not done fully. Aspose does some autofitting but it can be further autofitted. Its as if like that.
So, my second question is that if I am autofitting on merged cells Row 1 gets 10.5 but Row 2 and subsequent rows are getting 11.25.
PLEASE NOTE: the individual columns are 3 units wide - you can see that in the sample excel. That should remain as is.
PROBLEM 3 (MAIN CONCERN):
I want to give a min height consistently. Meaning 10.5 when I autofit, I want that to be 12.
I want that the row height (in both sheets) should 12 always and if the text increases then it should expand only - but min height should be 12 always.
ANY WAY I CAN DO THIS?Aspose_Sample_Merged_cells.zip (7.7 KB)