Bug 21884 - [RFE] Functions to hide gridlines of excel sheet using HSSF package not working
Summary: [RFE] Functions to hide gridlines of excel sheet using HSSF package not working
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.0-pre2
Hardware: PC All
: P3 normal with 4 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-25 13:00 UTC by arshi singh
Modified: 2005-03-20 17:06 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description arshi singh 2003-07-25 13:00:16 UTC
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();
 }
Comment 1 Andy Oliver 2003-07-25 13:55:24 UTC
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. 
Comment 2 Shawn Laubach 2003-07-25 14:19:37 UTC
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.
Comment 3 Andy Oliver 2003-07-25 14:33:34 UTC
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.
Comment 4 Shawn Laubach 2003-07-25 14:45:36 UTC
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.
 

Comment 5 arshi singh 2003-07-28 04:47:28 UTC
In which version can i find this newly added function. Currently i am using 
1.10. Should i look for it in 2.0
Comment 6 Andy Oliver 2003-07-28 12:37:25 UTC
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.