I have been using the apache.poi.hssf package for my project, version 1.10.0. I have made an excel sheet using HSSFSheet class in org.apache.poi.hssf.usermodel package. This class has the following 2 member functions for setting properties of gridlines on the sheet. void setGridsPrinted(boolean value) void setPrintGridlines(boolean newPrintGridlines) I tried to hide the gridlines using both these functions but they are not working. On the printout there are no gridlines but on the excel sheet that i view on my PC i still see them in the background. Where am i going wrong? The code is given below. import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.util.*; HSSFWorkbook wb; HSSFSheet sheet; HSSFRow sheet_row; ..... { .... FileReader fr= new FileReader("abc.txt"); BufferedReader br = new BufferedReader(fr); String sheetName="abc"; String fileName ="xyz.xls"; FileOutputStream fileOut = new FileOutputStream(fileName); wb = new HSSFWorkbook(); sheet = wb.createSheet(sheetName); /* Problem area */ sheet.setGridsPrinted(false); sheet.setPrintGridlines(false); .... .... wb.write(fileOut); fileOut.close(); fr.close(); }
I really wish you'd begin by asking this as a question on the list and verify that these do what you think before filing a bug.
Keyword in the code below is print. That only turns gridlines off in the printout. To answer the question, it is not possible with the current code. Give me about 30 more minutes and it should be implemented.
please don't stick this in 2.0 unless its stable and innoculous. We need to work towards having less bugs in 2.0 so we can release it and focus on 3.0. Its you're call of course.
Didn't get your email until after the commit but it meets your conditions. It is just more code of the type I'm good at. 1. Catch a record object and keep the reference (both in create and load). 2. Add a couple of procedures that access values in the record object 3. Give usermodel to said methods. I did go a step further and found where the particular reference to the record was being retreived in a search and switched these over. All hssf test cases ran and I can say that I improved performance (not enought to see but it is still an improvement). So...... In answer to the question, to turn the display of gridlines off in the viewer, i.e. Excel, etc, make the following addition to your code. sheet = wb.createSheet(sheetName); /* Problem area */ sheet.setGridsPrinted(false); sheet.setPrintGridlines(false); +sheet.setDisplayGridlines(false); All of this brings up another issue, we have two methods that do the exact same thing, setGridsPrinted and setPrintGridlines in HSSFSheet, but that is another issue.
In which version can i find this newly added function. Currently i am using 1.10. Should i look for it in 2.0
Either in the CVS REL_2_0 branch (check it out and build it) or wait a few days for the 2.0-pre3 release.