Shape.setName does not work on Excel 2007 but it works on Excel 2013 using Aspose.Cells for Java

The issue appeared in excel2013, excel 2007 is OK.

@daichao1225,

Thanks for the template file, sample code and screenshot.

After an initial test, I am able to reproduce the issue as you mentioned. I found by setting a checkbox linked cell causes MS Excel (2013) to prompts an error message when opening the output file into it. I used the sample code and template file provided by you. The issue does not occur in MS Excel 2007 though.

I have logged a ticket with an id “CELLSJAVA-42470” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.

@daichao1225,

This is to inform you that we have fixed your issue (logged earlier as “CELLSJAVA-42470”) now. We will soon provide you the fix after performing QA and incorporating other enhancements and fixes.

Once the fix is available for public use, we will share the Download link here.

How about the fixed version. Please let me know the recent result.

@daichao1225,

Please try our latest version/fix: Aspose.Cells for Java v17.11.5.

Your issue “CELLSJAVA-42470” should be fixed in it.

Let us know your feedback

Please send it to my email daichao1@huawei.com, thanks. I’ll reply you after test.

@daichao1225

Email sent to you with attachment. Hopefully, you will receive it successfully.

The issue “CELLSJAVA-42470” is OK, but “ELLSJAVA-42444” appeared again.

@daichao1225

CELLSJAVA-42444 is working fine. Please see the screenshot given below.

Here is the sample code and the output Excel file generated by the code for your reference.

Output Excel File By 17.11.5.zip (8.9 KB)

Java

Workbook workbook = new Workbook(dirPath + "222.xlsx");
WorksheetCollection sheets = workbook.getWorksheets();
int len = sheets.getCount();

for (int i = 0; i < len; i++) {
	Worksheet sheet = sheets.get(i);
	if (!sheet.isVisible()) {
		continue;
	}
	ShapeCollection shapes = sheet.getShapes();
	for (int j = 0; j < shapes.getCount(); j++) {
		Shape shape = shapes.get(j);
		if (shape.getMsoDrawingType() == MsoDrawingType.RADIO_BUTTON
				|| shape.getMsoDrawingType() == MsoDrawingType.CHECK_BOX) {
			CheckBox ch = (CheckBox) shape;
			ch.setName("GGGGGHHH");
			System.out.println(ch.getName());
		}
	}
}

workbook.save(dirPath + "out" + CellsHelper.getVersion() + ".xlsx");

Screenshot

I run the codes you send me and open it with WS 2007. The checkbox’s name hasn’t change.screenshot.zip (13.7 KB)

@daichao1225

Please also provide us your sample code. The sample code should be exact. Because there is ambiguity between 2.xlsx and 222.xlsx. I am not sure which one is your input Excel file. Please share the non-ambiguous code which shows clearly the input and output Excel file names.

Blow is the sample code and attach files.

@org.junit.Test
    public void test1208() throws Exception
    {
        Workbook workbook = new Workbook("D:\\1.xlsx");
        WorksheetCollection sheets = workbook.getWorksheets();
        int len = sheets.getCount();
        
        for (int i = 0; i < len; i++)
        {
            Worksheet sheet = sheets.get(i);
            if (!sheet.isVisible())
            {
                continue;
            }
            ShapeCollection shapes = sheet.getShapes();
            for (int j = 0; j < shapes.getCount(); j++)
            {
                Shape shape = shapes.get(j);
                if (shape.getMsoDrawingType() == MsoDrawingType.RADIO_BUTTON
                        || shape.getMsoDrawingType() == MsoDrawingType.CHECK_BOX)
                {
                    CheckBox ch = (CheckBox)shape;
                    ch.setName("GGGGGHHH");
                    System.out.println(ch.getName());
                }
            }
        }
        
        workbook.save("D:\\2.xlsx");
    }

input&output file.zip (16.7 KB)

@daichao1225

Thanks for using Aspose APIs.

If you open 1.xlsx in Microsoft Excel and re-save it, it will work ok. However, this bug needs to be fixed. We have logged it in our database for investigation and for resolution. Once, there is some news for you, we will let you know.

This issue has been logged as

  • CELLSJAVA-42481 - Set combo box name does not work for the source Excel file but if re-saved by Microsoft Excel it works ok

Java

Workbook wb = new Workbook(dirPath + "1.xlsx");

Worksheet ws = wb.getWorksheets().get("Sheet1");

ws.getCheckBoxes().get(0).setName("Paper");

wb.save(dirPath + "output.xlsx");

@daichao1225,

This is to inform you that we have fixed your issue (logged earlier as “CELLSJAVA-42481”) now. We will soon provide you the fix after performing QA and incorporating other enhancements and fixes.

Once the fix is available for public use, we will share the Download link here.

The issues you have found earlier (filed as CELLSJAVA-42470;CELLSJAVA-42481) have been fixed in this Aspose.Cells for Java 17.12 update.

Please also check the following document/blog for your reference: