You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2009/01/06 21:49:03 UTC
svn commit: r732112 - in /poi/trunk/src: documentation/content/xdocs/
java/org/apache/poi/hssf/usermodel/
ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/
ooxml/java/org/apache/poi/xssf/usermodel/
testcases/org/apache/poi/hssf/data/ testcases/org/ap...
Author: nick
Date: Tue Jan 6 12:49:02 2009
New Revision: 732112
URL: http://svn.apache.org/viewvc?rev=732112&view=rev
Log:
Support for reading HSSF column styles
Added:
poi/trunk/src/testcases/org/apache/poi/hssf/data/ColumnStyle1dp.xls (with props)
poi/trunk/src/testcases/org/apache/poi/hssf/data/ColumnStyle1dpColoured.xls (with props)
poi/trunk/src/testcases/org/apache/poi/hssf/data/ColumnStyleNone.xls (with props)
Modified:
poi/trunk/src/documentation/content/xdocs/changes.xml
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
poi/trunk/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=732112&r1=732111&r2=732112&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Tue Jan 6 12:49:02 2009
@@ -37,6 +37,7 @@
<!-- Don't forget to update status.xml too! -->
<release version="3.5-beta5" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="add">Support for reading HSSF column styles</action>
<action dev="POI-DEVELOPERS" type="fix">Hook up POIXMLTextExtractor.getMetadataTextExtractor() to the already written POIXMLPropertiesTextExtractor</action>
<action dev="POI-DEVELOPERS" type="fix">46472 - Avoid NPE in HPSFPropertiesExtractor when no properties exist</action>
<action dev="POI-DEVELOPERS" type="fix">46479 - fixed bugs related to cached formula values and HSSFFormulaEvaluator.evaluateInCell()</action>
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=732112&r1=732111&r2=732112&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Tue Jan 6 12:49:02 2009
@@ -34,6 +34,7 @@
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.5-beta5" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="add">Support for reading HSSF column styles</action>
<action dev="POI-DEVELOPERS" type="fix">Hook up POIXMLTextExtractor.getMetadataTextExtractor() to the already written POIXMLPropertiesTextExtractor</action>
<action dev="POI-DEVELOPERS" type="fix">46472 - Avoid NPE in HPSFPropertiesExtractor when no properties exist</action>
<action dev="POI-DEVELOPERS" type="fix">46479 - fixed bugs related to cached formula values and HSSFFormulaEvaluator.evaluateInCell()</action>
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java?rev=732112&r1=732111&r2=732112&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java Tue Jan 6 12:49:02 2009
@@ -36,6 +36,7 @@
import org.apache.poi.hssf.record.CellValueRecordInterface;
import org.apache.poi.hssf.record.DVRecord;
import org.apache.poi.hssf.record.EscherAggregate;
+import org.apache.poi.hssf.record.ExtendedFormatRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RowRecord;
import org.apache.poi.hssf.record.SCLRecord;
@@ -502,6 +503,23 @@
{
sheet.setDefaultRowHeight((short) (height * 20));
}
+
+ /**
+ * Returns the HSSFCellStyle that applies to the given
+ * (0 based) column, or null if no style has been
+ * set for that column
+ */
+ public HSSFCellStyle getColumnStyle(int column) {
+ short styleIndex = sheet.getXFIndexForColAt((short)column);
+
+ if(styleIndex == 0xf) {
+ // None set
+ return null;
+ }
+
+ ExtendedFormatRecord xf = book.getExFormatAt(styleIndex);
+ return new HSSFCellStyle(styleIndex, xf, book);
+ }
/**
* get whether gridlines are printed.
Modified: poi/trunk/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java?rev=732112&r1=732111&r2=732112&view=diff
==============================================================================
--- poi/trunk/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java (original)
+++ poi/trunk/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java Tue Jan 6 12:49:02 2009
@@ -177,6 +177,19 @@
* @param height default row height
*/
void setDefaultRowHeightInPoints(float height);
+
+ /**
+ * Returns the CellStyle that applies to the given
+ * (0 based) column, or null if no style has been
+ * set for that column
+ */
+ public CellStyle getColumnStyle(int column);
+
+ /**
+ * Sets the CellStyle that applies to the given
+ * (0 based) column.
+ */
+// public CellStyle setColumnStyle(int column, CellStyle style);
/**
* Adds a merged region of cells (hence those cells form one)
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=732112&r1=732111&r2=732112&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Tue Jan 6 12:49:02 2009
@@ -500,6 +500,17 @@
worksheet.getSheetFormatPr() :
worksheet.addNewSheetFormatPr();
}
+
+ /**
+ * Returns the CellStyle that applies to the given
+ * (0 based) column, or null if no style has been
+ * set for that column
+ */
+ public CellStyle getColumnStyle(int column) {
+ // TODO
+ return null;
+ }
+
/**
* Get whether to display the guts or not,
Added: poi/trunk/src/testcases/org/apache/poi/hssf/data/ColumnStyle1dp.xls
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/data/ColumnStyle1dp.xls?rev=732112&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/src/testcases/org/apache/poi/hssf/data/ColumnStyle1dp.xls
------------------------------------------------------------------------------
svn:executable = *
Propchange: poi/trunk/src/testcases/org/apache/poi/hssf/data/ColumnStyle1dp.xls
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: poi/trunk/src/testcases/org/apache/poi/hssf/data/ColumnStyle1dpColoured.xls
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/data/ColumnStyle1dpColoured.xls?rev=732112&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/src/testcases/org/apache/poi/hssf/data/ColumnStyle1dpColoured.xls
------------------------------------------------------------------------------
svn:executable = *
Propchange: poi/trunk/src/testcases/org/apache/poi/hssf/data/ColumnStyle1dpColoured.xls
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: poi/trunk/src/testcases/org/apache/poi/hssf/data/ColumnStyleNone.xls
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/data/ColumnStyleNone.xls?rev=732112&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/src/testcases/org/apache/poi/hssf/data/ColumnStyleNone.xls
------------------------------------------------------------------------------
svn:executable = *
Propchange: poi/trunk/src/testcases/org/apache/poi/hssf/data/ColumnStyleNone.xls
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java?rev=732112&r1=732111&r2=732112&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java Tue Jan 6 12:49:02 2009
@@ -911,4 +911,43 @@
}
wb.createSheet(SAME_PREFIX + "Exxxx"); // OK - differs in the 31st char
}
+
+ /**
+ * Tests that we can read existing column styles
+ */
+ public void testReadColumnStyles() {
+ HSSFWorkbook wbNone = HSSFTestDataSamples.openSampleWorkbook("ColumnStyleNone.xls");
+ HSSFWorkbook wbSimple = HSSFTestDataSamples.openSampleWorkbook("ColumnStyle1dp.xls");
+ HSSFWorkbook wbComplex = HSSFTestDataSamples.openSampleWorkbook("ColumnStyle1dpColoured.xls");
+
+ // Presence / absence checks
+ assertNull(wbNone.getSheetAt(0).getColumnStyle(0));
+ assertNull(wbNone.getSheetAt(0).getColumnStyle(1));
+
+ assertNull(wbSimple.getSheetAt(0).getColumnStyle(0));
+ assertNotNull(wbSimple.getSheetAt(0).getColumnStyle(1));
+
+ assertNull(wbComplex.getSheetAt(0).getColumnStyle(0));
+ assertNotNull(wbComplex.getSheetAt(0).getColumnStyle(1));
+
+ // Details checks
+ HSSFCellStyle bs = wbSimple.getSheetAt(0).getColumnStyle(1);
+ assertEquals(62, bs.getIndex());
+ assertEquals("#,##0.0_ ;\\-#,##0.0\\ ", bs.getDataFormatString());
+ assertEquals("Calibri", bs.getFont(wbSimple).getFontName());
+ assertEquals(11*20, bs.getFont(wbSimple).getFontHeight());
+ assertEquals(8, bs.getFont(wbSimple).getColor());
+ assertFalse(bs.getFont(wbSimple).getItalic());
+ assertEquals(HSSFFont.BOLDWEIGHT_NORMAL, bs.getFont(wbSimple).getBoldweight());
+
+
+ HSSFCellStyle cs = wbComplex.getSheetAt(0).getColumnStyle(1);
+ assertEquals(62, cs.getIndex());
+ assertEquals("#,##0.0_ ;\\-#,##0.0\\ ", cs.getDataFormatString());
+ assertEquals("Arial", cs.getFont(wbComplex).getFontName());
+ assertEquals(8*20, cs.getFont(wbComplex).getFontHeight());
+ assertEquals(10, cs.getFont(wbComplex).getColor());
+ assertFalse(cs.getFont(wbComplex).getItalic());
+ assertEquals(HSSFFont.BOLDWEIGHT_BOLD, cs.getFont(wbComplex).getBoldweight());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org