aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorJason Height <jheight@apache.org>2006-08-28 04:44:32 +0000
committerJason Height <jheight@apache.org>2006-08-28 04:44:32 +0000
commita2d9acef5602392d5a117355c44e7f97074c703d (patch)
treed3dd9358b0563534c24b054bf8f9719e4c142d3f /src/java
parentd4b421b471d495fec1e782beed2dc8bb010c4474 (diff)
downloadpoi-a2d9acef5602392d5a117355c44e7f97074c703d.tar.gz
poi-a2d9acef5602392d5a117355c44e7f97074c703d.zip
Bug 33736: Applied patch for Column Hiding. Thanks
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@437526 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/poi/hssf/model/Sheet.java45
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java23
2 files changed, 68 insertions, 0 deletions
diff --git a/src/java/org/apache/poi/hssf/model/Sheet.java b/src/java/org/apache/poi/hssf/model/Sheet.java
index 1ee2bb8fd2..01b78771a2 100644
--- a/src/java/org/apache/poi/hssf/model/Sheet.java
+++ b/src/java/org/apache/poi/hssf/model/Sheet.java
@@ -47,6 +47,7 @@ import java.util.List; // normally I don't do this, buy we literally mean ALL
* @author Shawn Laubach (slaubach at apache dot org) Gridlines, Headers, Footers, PrintSetup, and Setting Default Column Styles
* @author Jason Height (jheight at chariot dot net dot au) Clone support. DBCell & Index Record writing support
* @author Brian Sanders (kestrel at burdell dot org) Active Cell support
+ * @author Jean-Pierre Paris (jean-pierre.paris at m4x dot org) (Just a little)
*
* @see org.apache.poi.hssf.model.Workbook
* @see org.apache.poi.hssf.usermodel.HSSFSheet
@@ -1843,6 +1844,50 @@ public class Sheet implements Model
setColumn( column, new Short(width), null, null, null);
}
+ /**
+ * Get the hidden property for a given column.
+ * @param column index
+ * @see org.apache.poi.hssf.record.DefaultColWidthRecord
+ * @see org.apache.poi.hssf.record.ColumnInfoRecord
+ * @see #setColumnHidden(short,boolean)
+ * @return whether the column is hidden or not.
+ */
+
+ public boolean isColumnHidden(short column)
+ {
+ boolean retval = false;
+ ColumnInfoRecord ci = null;
+
+ if (columns != null)
+ {
+ for ( Iterator iterator = columns.getIterator(); iterator.hasNext(); )
+ {
+ ci = ( ColumnInfoRecord ) iterator.next();
+ if ((ci.getFirstColumn() <= column)
+ && (column <= ci.getLastColumn()))
+ {
+ break;
+ }
+ ci = null;
+ }
+ }
+ if (ci != null)
+ {
+ retval = ci.getHidden();
+ }
+ return retval;
+ }
+
+ /**
+ * Get the hidden property for a given column.
+ * @param column - the column number
+ * @param hidden - whether the column is hidden or not
+ */
+ public void setColumnHidden(short column, boolean hidden)
+ {
+ setColumn( column, null, null, new Boolean(hidden), null);
+ }
+
public void setColumn(short column, Short width, Integer level, Boolean hidden, Boolean collapsed)
{
if (columns == null)
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
index fa207870f1..c7befce1be 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
@@ -41,6 +41,7 @@ import java.util.TreeMap;
* @author Glen Stampoultzis (glens at apache.org)
* @author Libin Roman (romal at vistaportal.com)
* @author Shawn Laubach (slaubach at apache dot org) (Just a little)
+ * @author Jean-Pierre Paris (jean-pierre.paris at m4x dot org) (Just a little, too)
*/
public class HSSFSheet
@@ -340,6 +341,28 @@ public class HSSFSheet
}
/**
+ * Get the visibility state for a given column.
+ * @param column - the column to get (0-based)
+ * @param width - the visiblity state of the column
+ */
+
+ public void setColumnHidden(short column, boolean hidden)
+ {
+ sheet.setColumnHidden(column, hidden);
+ }
+
+ /**
+ * Get the hidden state for a given column.
+ * @param column - the column to set (0-based)
+ * @return hidden - the visiblity state of the column
+ */
+
+ public boolean isColumnHidden(short column)
+ {
+ return sheet.isColumnHidden(column);
+ }
+
+ /**
* set the width (in units of 1/256th of a character width)
* @param column - the column to set (0-based)
* @param width - the width in units of 1/256th of a character width