Conditional Formatting -- Not working when using copyRow

Hi,

I am trying to copy row from one sheet to another sheet including all formats using the below snippet. But the conditional formats are not getting copied in the new rows.

Workbook workbook = new Workbook("d:\\Test.xlsx");

Worksheet worksheet = workbook.getWorksheets().get(0);

Cells cells=worksheet.getCells();

Workbook workbook1=new Workbook();

Worksheet worksheet1=workbook.getWorksheets().get(0);

Cells cells1=worksheet1.getCells();

cells1.copyRow(cells, 1,1);

cells1.copyRow(cells, 2,2);

workbook1.save("d:\\Test1.xlsx");

The files are attached. Please look into the issue and let me know the updates.

Regards,

Sri

Hi,

Thanks for your posting and using Aspose.Cells for Java.

I was able to replicate this issue using the latest version:
Aspose.Cells
for Java v7.2.1.7


I have attached the screenshot for a reference.

Java


String filePath = “F:\Shak-Data-RW\Downloads\Test.xlsx”;


Workbook workbook = new Workbook(filePath);


Worksheet worksheet = workbook.getWorksheets().get(0);


Cells cells=worksheet.getCells();


Workbook workbook1=new Workbook();


Worksheet worksheet1=workbook1.getWorksheets().get(0);


Cells cells1=worksheet1.getCells();


cells1.copyRow(cells, 1,1);


cells1.copyRow(cells, 2,2);


workbook1.save(filePath + “.out.xlsx”);


Screenshot:

Hi,

Thanks and appreciate for your quick reply. Is there any another alternative workaround?

Regards,

Sri

Hi,

After looking into further, I found, when you copy rows from one workbook into another workbook in Ms-Excel 2010 manually, then conditional formatting is lost.

So it is not a bug.

But when you copy rows from one worksheet into another worksheet inside a same workbook, conditional formatting is preserved.

As a workaround, I will suggest you to add a new worksheet in a same workbook and copy your rows into newly added worksheet and then delete all other worksheets, it should then work fine.

Hi Shakeel,

When I copy rows manually to another workbook, the conditional formats are also copied. Its works fine and conditional formatting is preserved when we do manually in MS-Excel 2010 between different workbooks.

Using the beow snippet, we do copy to another sheet within the same workbook, the conditional formats are lost.

Workbook workbook = new Workbook("d:\\Test.xlsx");

Worksheet worksheet = workbook.getWorksheets().get(0);

Cells cells=worksheet.getCells();

Worksheet worksheet1=workbook.getWorksheets().add("Test1");

Cells cells1=worksheet1.getCells();

cells1.copyRow(cells, 1,1);

cells1.copyRow(cells, 2,2);

workbook.save("d:\\Test.xlsx");

Regards,

Sri

Hi,

Thanks for your feedback.

I was able to notice the problem and logged this issue for investigation.

We will look into your issue and once the issue is fixed or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSJAVA-40202.

Hi,

We have fixed this issue. Please download and try the latest version: Aspose.Cells for Java v7.2.1.8

Thanks Shakeel. Will check and let you know.

Regards,

Sri

The issues you have found earlier (filed as CELLSJAVA-40202) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.