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

Aspose.cells 16.12.0 shape.setName do not work on excel2007, but excel2013 is OK.
I want use shape.setName to change checkbox’s name in excel. But it doesn’t work on excel2007.
please help, thanks.

@daichao1225,

Thanks for providing us details.

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

If you still find the issue, kindly paste your JAVA program, and attach template files (input file (if any) and output file), we will check it soon.

The issue appeared again in the latest version 17.10.3.
The java program is like this:

public static void main(String[] args) throws Exception
    {
        InputStream input = null;
        OutputStream output = null;
        input = new FileInputStream("D:\\222.xlsx");
        Workbook workbook = new Workbook(input);
        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());
                }
            }
        }
        
        output = new FileOutputStream("D:\\2.xlsx");
        XlsSaveOptions saveOptions = new XlsSaveOptions(SaveFormat.XLSX);
        workbook.save(output, saveOptions);
        System.out.println("1");
    }

input and output files:template files.zip (17.7 KB)

@daichao1225

Thanks for using Aspose.Cells.

We checked your issue on Excel 2016 and found, it is working fine. Please see the following screenshot.

Please provide us the screenshots of Excel 2007 so that we could look into it further.

Screenshot:

@daichao1225

Thanks for using Aspose APIs.

After looking into your code, we found an error. We think, this error code is causing you issue. Please change this line

//XlsSaveOptions is invalid for XLSX format
XlsSaveOptions saveOptions = new XlsSaveOptions(SaveFormat.XLSX);

into

//OoxmlSaveOptions is correct for XLSX format
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.XLSX); 

It should fix your issue. Let us know your feedback.

It’s fine when you open with excel 2016 or 2017 except 2007. If you open it with 2007, you will find the issue.

We change the program like you provided, but the issue also appeared.

@daichao1225

Thanks for using Aspose APIs.

We were able to observe this issue and logged it in our database for investigation and for a fix. Once, the issue is resolved or we have some other news for you, we will update you asap.

This issue has been logged as

  • CELLSJAVA-42444 - CheckBox.setName() method works in Excel 2016 but does not work in Excel 2007

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.xlsx");

Excel 2007 - Screenshot

How long will it takes

@daichao1225

Thanks for using Aspose APIs.

This is to inform you that we have fixed your issue CELLSJAVA-42444 now. We will soon provide the fix after performing QA and including other enhancements and fixes.

We want to know the fix time, then we can do a better plan. Thanks.

@daichao1225,

You should be getting the fix in the next few days (2-3 days or so).

We will share the Download link here once the fix is available for public use.

Nice, appreciate for your support.

@daichao1225

Please download and try the following fix and let us know your feedback.

I have no privilege to access “Personal Network Storage” category. Could you send it to my email( daichao1@huawei.com ), thanks.

@daichao1225,

An email with attachment is sent @ your mentioned email id.

The issues you have found earlier (filed as CELLSJAVA-42444) have been fixed in this Aspose.Cells for Java 17.11 update.

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

Thanks, the issues is fixed in this release.

@daichao1225

Thanks for your feedback and using Aspose.Cells.

It is good to know that your issue is resolved with the latest fix. Let us know if you encounter any other issue, we will be glad to look into it and help you further.

Hi, we find a new issue in Aspose.Cells for Java 17.11. When the checkbox set linked cell, when opening the saved excel will throw problem to fix it. The excel tips’ screenshots and excel fileexcel tips.png (8.4 KB)
excel files and screenshots.zip (29.1 KB)
are attached in upload files.
Here is the code.
@Test
public void test1130() throws Exception
{
InputStream input = null;
OutputStream output = null;
input = new FileInputStream(“D:\1.xlsx”);
Workbook workbook = new Workbook(input);
WorksheetCollection sheets = workbook.getWorksheets();
// sheets.add(“Hide”).setVisible(false);
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.CHECK_BOX)
{
CheckBox ch = (CheckBox)shape;
ch.setLinkedCell(“A1”);
ch.getId();
ch.setName(“GGGGGHHH”);
System.out.println(ch.getName());
}
Cells Cell = sheet.getCells();
Cell ce = Cell.get(0, 0);
ce.setValue(“1”);
}
}

    output = new FileOutputStream("D:\\2.xlsx");
    OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.XLSX);
    workbook.save(output, saveOptions);
    System.out.println("1");
}