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.

Thu Mar 07, 2019 9:23 am

Hello

I try to copy a range from the sheet a on the sheet b, I can't keep formatting for merged cells.

CellRange DataRange = sheetaux.Range[1, 1, colnr == 0 ? 1 : colnr, lastColumnAux];

CellRange targetDataRange = sheet.Range[index, firstColumn, index, lastColumn];

sheetaux.Copy(DataRange, targetDataRange, true);

What can I do?

Thx.

1.PNG
Source
1.PNG (14.24 KiB) Viewed 1512 times


2.PNG
Destination
2.PNG (24.7 KiB) Viewed 1512 times

B3ni
 
Posts: 5
Joined: Fri May 04, 2018 6:14 am

Thu Mar 07, 2019 10:08 am

Hello,

Thanks for your inquiry.
After an initial test with our latest Spire.XLS Pack(Hotfix) Version:9.2.11, I did not reproduce your issue. Please provide your testing Excel files to help us further investigate it. You could send them us via email (support@e-iceblue.com). Thanks in advance.

Sincerely,
Lisa
E-iceblue support team
Last edited by Lisa.Li on Thu Mar 07, 2019 10:15 am, edited 1 time in total.
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Thu Mar 07, 2019 10:13 am

I use the free version, maybe this is that the cause...?

B3ni
 
Posts: 5
Joined: Fri May 04, 2018 6:14 am

Thu Mar 07, 2019 10:36 am

Hello,

Thank you for sharing your test file.
I have reproduced the issue with your Excel file and logged it into our bug tracking system for fixing, if there is any update, I will let you know. Sorry for the inconvenience caused.

Sincerely,
Lisa
E-iceblue
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Thu Mar 07, 2019 10:48 am

Thank you!

B3ni
 
Posts: 5
Joined: Fri May 04, 2018 6:14 am

Mon Mar 11, 2019 6:57 am

Hello,

Greetings from E-iceblue.
After further investigation, there is a parameter "bool updateReference" in one of the overloaded methods of Worksheet.Copy() which is designed practically for keeping formatting for merged cells. Please try the following code snippet to achieve it. If there is any question, just feel free to write back.
Code: Select all
......
sheetaux.Copy(DataRange, targetDataRange, true,true,true);
......

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Mon Mar 11, 2019 7:19 am

Hello,

It works :D

Thx Lisa

B3ni
 
Posts: 5
Joined: Fri May 04, 2018 6:14 am

Mon Mar 11, 2019 9:06 am

Hello,

Glad to hear that!
If you encounter any issue related to our products in the future, just feel free to contact us. Wish you all the best!

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.XLS