Bug 53678 - Clone Sheet with control form (Checkboxes)
Summary: Clone Sheet with control form (Checkboxes)
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.8-FINAL
Hardware: PC Windows Vista
: P2 major with 5 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2012-08-08 09:45 UTC by Benjamin
Modified: 2013-03-08 15:15 UTC (History)
1 user (show)

Excel file passed in argument (10.55 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2012-08-08 09:45 UTC, Benjamin
The original file with Form Control (28.99 KB, application/vnd.ms-excel.sheet.macroEnabled.12)
2013-03-08 15:09 UTC, Tom Cole
The Cloned Document (28.88 KB, application/vnd.ms-excel.sheet.macroEnabled.12)
2013-03-08 15:10 UTC, Tom Cole

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin 2012-08-08 09:45:37 UTC
Created attachment 29185 [details]
Excel file passed in argument

When cloning a sheet with checkboxes in it (control form type), the resulting file is corrupted.

Step to reproduce : use this with the file attached
    public static void main(String[] args) throws FileNotFoundException, IOException {
        Workbook wb = new XSSFWorkbook(new FileInputStream(args[0]));
        FileOutputStream fileOut = new FileOutputStream(args[0].replace(".xlsx", "-edited.xlsx"));

result : the second sheet is corrupted and do not have the checkbox
Comment 1 Tom Cole 2013-03-08 15:09:30 UTC
Created attachment 30027 [details]
The original file with Form Control

This is the original file. The first sheet has conditional formatting, some VB code, a macro and a Form Control Button.
Comment 2 Tom Cole 2013-03-08 15:10:08 UTC
Created attachment 30028 [details]
The Cloned Document

This is the newly created file with the first sheet cloned.
Comment 3 Tom Cole 2013-03-08 15:15:07 UTC
I believe this condition exists with any Form Control. I have attached a workbook where the first sheet has a form control button on it. If you clone that sheet, the generated sheet has errors in it. If you remove the form control, the sheet clones just fine (even with conditional formatting).

I used the following program to clone the original:

public class ReadWriteTest {

	public ReadWriteTest(String input, String output) {
		try {
			File inputFile = new File(input);
			if (inputFile.exists()) {
				Workbook excel = new XSSFWorkbook(new FileInputStream(inputFile));
				Sheet newSheet = excel.cloneSheet(0);
				excel.setSheetName(excel.getSheetIndex(newSheet), "Clone");
				File outputFile = new File(output);
				boolean create = ! outputFile.exists();
				if (! create) {
					create = (JOptionPane.showConfirmDialog(null, "File exists, do you want to overwrite?") == JOptionPane.OK_OPTION);
				if (create) {
					excel.write(new FileOutputStream(outputFile));
			else {
				System.out.println("Input file " + input + " not found.");
		catch(Exception ex) {
	public static void main(String[] args) {
		if (args.length == 2) {
			new ReadWriteTest(args[0], args[1]);
		else {
			System.out.println("USAGE: ReadWriteTest <input_file_name> <output_file_name>");