Bug 62651 - setting setDisplayGridlines(false) on the first sheet causes all sheets to hide their gridlines
Summary: setting setDisplayGridlines(false) on the first sheet causes all sheets to hi...
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: SXSSF (show other bugs)
Version: 3.17-FINAL
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-23 16:26 UTC by diarmuid
Modified: 2018-12-28 20:03 UTC (History)
0 users



Attachments
output of gist reproducing case with unexpected behaviour (4.77 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2018-08-24 10:18 UTC, diarmuid
Details
output of gist reproducing case with expected behaviour (4.76 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2018-08-24 10:19 UTC, diarmuid
Details

Note You need to log in before you can comment on or make changes to this bug.
Description diarmuid 2018-08-23 16:26:41 UTC
In a SXSSFWorkbook with multiple SXSSFSheet :


Action : calling sxssfSheet.setDisplayGridlines(false) on 2nd or subsequent sheets in workbook 
Expectation  : only those sheets set as above should have their gridlines hidden
Result: Behaves as Expected 

Action : calling sxssfSheet.setDisplayGridlines(false) only on 1st sheet in workbook 
Expectation  : only 1st sheet should have it's gridlines hidden
Result: Does not behave as expected . All sheets in workbook have their gridlines hidden 



Summary 
calling sxssfSheet.setDisplayGridlines(false) behaves as expected if sxssfSheet is not the first sheet in the workbook 
Otherwise all sheets' gridlines will be hidden
Comment 1 diarmuid 2018-08-24 10:15:06 UTC
Here's a Gist to reproduce the issue - resulting files attached 

package go.figure;

import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;

public class PoiBug62651 {

	public static void caseWithExpectedBehaviour(){
		try (SXSSFWorkbook wb = new SXSSFWorkbook(1)) {
			wb.setCompressTempFiles(true);
			wb.createSheet("1st").setDisplayGridlines(true);
			wb.createSheet("2nd").setDisplayGridlines(false);
			wb.createSheet("3rd").setDisplayGridlines(true);
			wb.createSheet("4th").setDisplayGridlines(false);
			wb.createSheet("5th").setDisplayGridlines(true);
			try (FileOutputStream out = new FileOutputStream("PoiBug62651-" + "correct-behaviour-selected-sheets-hidden" + ".xlsx")) {
				wb.write(out);
			} finally {
				wb.dispose();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void caseWithUnexpectedBehaviour(){
		try (SXSSFWorkbook wb = new SXSSFWorkbook(1)) {
			wb.setCompressTempFiles(true);
			wb.createSheet("1st").setDisplayGridlines(false);
			wb.createSheet("2nd").setDisplayGridlines(false);
			wb.createSheet("3rd").setDisplayGridlines(true);
			wb.createSheet("4th").setDisplayGridlines(false);
			wb.createSheet("5th").setDisplayGridlines(true);
			try (FileOutputStream out = new FileOutputStream("PoiBug62651-" + "all-5-sheets-incorrectly-hide-grids" + ".xlsx")) {
				wb.write(out);
			} finally {
				wb.dispose();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		caseWithExpectedBehaviour();
		caseWithUnexpectedBehaviour();
	}

}


jdk version information :-

/usr/lib/jvm/java-8-openjdk-amd64/bin/java -version 
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-0ubuntu0.16.04.1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
Comment 2 diarmuid 2018-08-24 10:18:31 UTC
Created attachment 36109 [details]
output of gist reproducing case with unexpected behaviour
Comment 3 diarmuid 2018-08-24 10:19:07 UTC
Created attachment 36110 [details]
output of gist reproducing case with expected behaviour
Comment 4 Dominik Stadler 2018-12-26 18:02:46 UTC
I tried this with only LibreOffice (no POI) and had the same effect, so I fear this might be actually a bug in LibreOffice instead.

Please try this with Microsoft Excel and report if the files created by Apache POI are still not displayed correctly there as well.
Comment 5 diarmuid 2018-12-28 13:04:21 UTC
(In reply to Dominik Stadler from comment #4)
> I tried this with only LibreOffice (no POI) and had the same effect, so I
> fear this might be actually a bug in LibreOffice instead.
> 
> Please try this with Microsoft Excel and report if the files created by
> Apache POI are still not displayed correctly there as well.

Hi thanks for checking this 
I also have verifed that 
a) The issue does not manifest itself with Microsoft Excel 
b) Carrying out these operations only in LibreOffice ( not using POI api ) reproduces the issue . 

In light of this I think the bug may be closed and a bug opened with LibreOffice
Comment 6 Dominik Stadler 2018-12-28 20:03:05 UTC
Ok, thanks for the note, closing this bug then.