Sorry to not reply before today but with the recent rains everything has been
growing like topsy and we have been very busy keeping paths open. Anayway,
that aside, can I ask you to try this code please?
import java.io.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFSheet;
/**
*
* @author Mark Beardsley
*/
public class HidingTest {
public HidingTest(String filename) throws IOException {
File file = null;
FileOutputStream fos = null;
XSSFWorkbook workbook = null;
XSSFSheet sheet = null;
try {
workbook = new XSSFWorkbook();
sheet = workbook.createSheet();
this.populateSheet(sheet);
workbook.setSheetHidden(0, 2);
sheet = workbook.createSheet();
this.populateSheet(sheet);
sheet = workbook.createSheet();
this.populateSheet(sheet);
file = new File(filename);
fos = new FileOutputStream(file);
workbook.write(fos);
}
finally {
if(fos != null) {
fos.close();
}
}
}
private void populateSheet(Sheet sheet) {
Row row = sheet.createRow(0);
Cell cell = null;
for(int i = 0; i < 5; i++) {
cell = row.createCell(i);
cell.setCellValue(i + 1);
}
}
}
It is far from being a complete replacement for your code as it does not
select sheets nor make tabs active, but it ought to hide the sheet
successfully for you. If it does work, the key is in this line of code;
workbook.setSheetHidden(0, 2);
which replaces the setSheetHidden(int, boolean) method call. From looking at
the source for the Workbook class, it would appear that there are three
possible setting for the sheets visibility, visible, hidden or very hidden.
Passing the int value 2 as the argument to the second parameter of the
overloaded setSheetHidden(int, int) method, makes the sheet very hidden and
I think this might be the solution to your problem.
Yours
Mark B
--
View this message in context:
http://apache-poi.1045710.n5.nabble.com/Re-Tabs-on-workbook-with-hidden-sheets-tp5710502p5710522.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]