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.

Mon Jul 27, 2020 7:23 am

Hi,
I have text with long sentences and some line breaks, that should be insert to single Cell.
I tried to use AutoFitRows and IsWrapText each one separately, and both together, But the height of the line was not correct.
When I tried manually, by double clicking on the bottom line border, It worked properly.

Code sample:
sheet["B1"].ColumnWidth = 70;
sheet["B1"].Text = "row1\n row2\n row3\n row4\naaa bbb ccc ddd eee fff aaa bbb ccc ddd eee fff aaa bbb ccc ddd eee fff aaa bbb ccc ddd eee fff aaa bbb ccc ddd eee fff ";
sheet["B1"].IsWrapText = true;
sheet["B1"].AutoFitRows();

Can you help me please?
Thanks,

rivphill
 
Posts: 3
Joined: Wed Jul 22, 2020 6:12 am

Mon Jul 27, 2020 8:02 am

Hello,

Thanks for your inquiry.
Please comment out the line "sheet["B1"].AutoFitRows();" as shown below and download the latest Spire.XLS Pack(Hotfix) Version:10.7.2 for testing. If you have further questions, please feel free to let us know.
Code: Select all
            Workbook wb = new Workbook();
            CellRange sheet = wb.Worksheets[0].Range;
            sheet["B1"].ColumnWidth = 70;
            sheet["B1"].Text = "row1\n row2\n row3\n row4\naaa bbb ccc ddd eee fff aaa bbb ccc ddd eee fff aaa bbb ccc ddd eee fff aaa bbb ccc ddd eee fff aaa bbb ccc ddd eee fff ";
            sheet["B1"].IsWrapText = true;
            //sheet["B1"].AutoFitRows(); //comment out
            wb.SaveToFile("out.xlsx", FileFormat.Version2013);


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Mon Jul 27, 2020 1:48 pm

Thanks! It's really works!
Now, I have other issue - It's not working on merged cells
Apparently because Excel itself does not support it.
So I temporarily inserted the text into another cell with the same width of the merged cells in order to measure its height, and manually edit the height of the merged cells.
The problem is that the property RowHeight is probably set in display mode, and in the code it remains the original size.
Do you have any idea how can I get the final row height while building the document?
(maybe command to update display like "UpdateLayout" in WPF?)
Thanks.

rivphill
 
Posts: 3
Joined: Wed Jul 22, 2020 6:12 am

Tue Jul 28, 2020 6:46 am

Hello,

Thanks for your feedback.
Do you mean you want to get the new row height after setting the IsWrapText property? I learned from our Dev team that the IsWrapText is just a layout property, it does not really change the row height value in the internal data of the Excel file. You need to use AutoFitRows to recalculate the row height.
But unfortunately, as you mentioned in your first post, the row height of the output file generated using the AutoFitRows method is incorrect. I have posted this issue to our Dev team with the ticket SPIREXLS-2585 for further investigation. We will let you know if there is any update, sorry for the inconvenience caused.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Tue Jul 28, 2020 7:23 am

Yes, this is the exact definition of the problem.
I would appreciate receiving an update when the issue is resolved.
Thanks.

rivphill
 
Posts: 3
Joined: Wed Jul 22, 2020 6:12 am

Tue Jul 28, 2020 8:34 am

Hello,

Thanks for your prompt response.
If there is any good news, we will notify you ASAP.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Mon Dec 07, 2020 2:01 am

Hello,

Sorry for the long silence.
Glad to tell you that the issue SPIREXLS-2585 has been fixed in the newly released Spire.XLS Pack(Hotfix) Version:10.12.0. Welcome to download it from the following links.
Website link: https://www.e-iceblue.com/Download/down ... t-now.html
Nuget link: https://www.nuget.org/packages/Spire.XLS/10.12.0

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Thu Dec 10, 2020 6:38 am

Hello,

Greetings from E-iceblue!
Has your issue been resolved? Any feedback will be greatly appreciated!

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.XLS

cron