Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Wed Jan 26, 2022 9:01 pm

Hi

I tried to use the functions of WrapText and AutoFitRows in the merged cell.

There was no problem when writing long strings in the single-cell and using WrapText and AutoFitRows.

But, if it is merged, the functions are not working.
WrapText is a line change, but the height is fixed.
in that situation, when AutoFitRows is used, it is perceived as a single line and does not work.

Can you help me?

Sungkyu_min
 
Posts: 30
Joined: Fri Jan 07, 2022 5:53 am

Thu Jan 27, 2022 5:31 am

Hello,

Thank you for your inquiry.
I did a preliminary test and did reproduce the problem you mentioned. After investigation, I found that if you apply the WrapText method and the AutoFitRows method to the cells before merging the cells, this method can achieve the result you expect. But during testing I found that there is an issue with merged column cells, I have logged the issue into our bug tracking system with the ticket number SPIREXLS-3669. Our development team will investigate and fix it. Once it is resolved, I will inform you in time. Sorry for the inconvenience caused.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1648
Joined: Wed Apr 07, 2021 2:50 am

Fri Mar 04, 2022 9:13 am

Hello,

Hello,

Thanks for your patience!

Glad to inform that we just released Spire.XLS Pack(Hotfix) Version:12.3.2 which fixes the issue of SPIREXLS-3669, please download and refer to the sample code for testing.

Website link: https://www.e-iceblue.com/Download/download-excel-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.XLS/12.3.2
Code: Select all
Workbook workbook = new Workbook();
workbook.LoadFromFile(inputFile);
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Range["C2"].Style.WrapText = true;
worksheet.Range["C2"].AutoFitRows();
worksheet.Range["D2"].Style.WrapText = true;
worksheet.Range["D2"].AutoFitRows();
worksheet.Range["B4"].Style.WrapText = true;
worksheet.Range["B4"].AutoFitRows();
worksheet.Range["B5"].Style.WrapText = true;
worksheet.Range["B5"].AutoFitRows();

worksheet.Range["C2:D2"].Merge();
worksheet.Range["B4:B5"].Merge();
workbook.SaveToFile(resultFile, FileFormat.Version2010);

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1648
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.XLS

cron