poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 60561] New: Values wrote in the first visible sheet are overwriting hidden sheet values
Date Mon, 09 Jan 2017 11:07:24 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=60561

            Bug ID: 60561
           Summary: Values wrote in the first visible sheet are
                    overwriting hidden sheet values
           Product: POI
           Version: 3.16-dev
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: guill.sanon@gmail.com
  Target Milestone: ---

Hi,

When I create a XSSFWorkbook with a hidden sheet and two visible sheets : 
0 : "HiddenSheet"
1 : "DataSheet 1"
2 : "DataSheet 2"

All modifications done with Excel on the first visible "DataSheet 1" are
reported on the "HiddenSheet". 
Modifications done on the third sheet "DataSheet 2" has no effect neither on
"HiddenSheet" or "DataSheet 1"
Data wrote on the "DataSheet 1" shold not be reported on the "HiddenSheet"

I tried to modify with Excel 2007, Excel 2013same problem.
I tried to generate with Apache POI  3.15 avec 3.16-beta2 same problem. 
Use a very hidden sheet with "setHiddenSheet(0, 2)" correct the problem.

To reproduce generate a workbook with the code below then open the generated
file with Excel and modify values in the "DataSheet 1". Unhide the
"HiddenSheet" you will see the modifications you did on the "DataSheet 1"
copied on the "HiddenSheet".

Regards,

Exemple code :

import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class HiddenSheetTest {

        public static final int ROW_NUMBER = 15;
        public static final int COLUMN_NUMBER = 10;

        public static void main(String[] args) {

        Workbook wb = new XSSFWorkbook(); 
        Sheet hiddenSheet = wb.createSheet("HiddenSheet"); 
        Sheet dataSheet = wb.createSheet("DataSheet 1"); 
        Sheet dataSheet2 = wb.createSheet("DataSheet 2"); 
        populateSheetWithNumber(hiddenSheet, 5);
        populateSheetWithNumber(dataSheet, 10);
        populateSheetWithNumber(dataSheet2, 20);
        // set Active Sheet "DataSheet"
        wb.setActiveSheet(1);

        // Hide "hiddenSheet"
        wb.setSheetHidden(0, true);
        try {
                FileOutputStream out = new FileOutputStream("WBTest.xlsx");
                wb.write(out);
                out.close();
                        wb.close();
                } catch (IOException e) {
                        e.printStackTrace();
                }
        }

        private static void populateSheetWithNumber(Sheet sheet, int number)
        {
                for(int i = 0; i < ROW_NUMBER; i++)
                {
                        Row row = sheet.createRow(i);
                        for(int j = 0;  j < COLUMN_NUMBER; j++)
                        {
                                Cell cell = row.createCell(j);
                                cell.setCellValue(number);
                        }
                }
        }
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Mime
View raw message