import org.apache.poi.hssf.record.aggregates.MergedCellsTable;
import org.apache.poi.hssf.record.aggregates.PageSettingsBlock;
import org.apache.poi.hssf.record.aggregates.RecordAggregate;
-import org.apache.poi.hssf.record.aggregates.RowRecordsAggregate;
-import org.apache.poi.hssf.record.aggregates.WorksheetProtectionBlock;
import org.apache.poi.hssf.record.aggregates.RecordAggregate.PositionTrackingVisitor;
import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor;
-import org.apache.poi.ss.formula.FormulaShifter;
+import org.apache.poi.hssf.record.aggregates.RowRecordsAggregate;
+import org.apache.poi.hssf.record.aggregates.WorksheetProtectionBlock;
import org.apache.poi.hssf.util.PaneInformation;
+import org.apache.poi.ss.formula.FormulaShifter;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Internal;
import org.apache.poi.util.POILogFactory;
protected PrintGridlinesRecord printGridlines = null;
protected GridsetRecord gridset = null;
private GutsRecord _gutsRecord;
- protected DefaultColWidthRecord defaultcolwidth = null;
- protected DefaultRowHeightRecord defaultrowheight = null;
+ protected DefaultColWidthRecord defaultcolwidth = new DefaultColWidthRecord();
+ protected DefaultRowHeightRecord defaultrowheight = new DefaultRowHeightRecord();
private PageSettingsBlock _psBlock;
/**
records.add(rec);
continue;
}
-
+
if (recSid == EOFRecord.sid) {
records.add(rec);
break;
public void removeRow(RowRecord row) {
_rowsAggregate.removeRow(row);
}
-
+
/**
* Get all the value records (from LOC). Records will be returned from the first
* record (starting at LOC) which is a value record.
* subsequent calls will return values in (physical) sequence or NULL when you get to the end.
*
* @return Array of CellValueRecordInterface representing the remaining value records
- * @deprecated use {@link #getValueIterator()} instead
+ * @deprecated use {@link #getCellValueIterator()} instead
*/
@Deprecated
public CellValueRecordInterface[] getValueRecords() {
DefaultRowHeightRecord retval = new DefaultRowHeightRecord();
retval.setOptionFlags(( short ) 0);
- retval.setRowHeight(( short ) 0xff);
+ retval.setRowHeight(DefaultRowHeightRecord.DEFAULT_ROW_HEIGHT);
return retval;
}
*/
private static DefaultColWidthRecord createDefaultColWidth() {
DefaultColWidthRecord retval = new DefaultColWidthRecord();
- retval.setColWidth(( short ) 8);
+ retval.setColWidth(DefaultColWidthRecord.DEFAULT_COLUMN_WIDTH);
return retval;
}
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
+
package org.apache.poi.hssf.record;
private short field_1_option_flags;
private short field_2_row_height;
+ /**
+ * The default row height for empty rows is 255 twips (255 / 20 == 12.75 points)
+ */
+ public static final short DEFAULT_ROW_HEIGHT = 0xFF;
+
public DefaultRowHeightRecord()
{
+ field_1_option_flags = 0x0000;
+ field_2_row_height = DEFAULT_ROW_HEIGHT;
}
public DefaultRowHeightRecord(RecordInputStream in)
assertEquals(40000, sh.getColumnWidth(0));
}
+
+ public void testDefaultColumnWidth() {
+ HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook( "12843-1.xls" );
+ HSSFSheet sheet = wb.getSheetAt( 7 );
+ // shall not be NPE
+ assertEquals(8, sheet.getDefaultColumnWidth());
+ assertEquals(8*256, sheet.getColumnWidth(0));
+
+ assertEquals(0xFF, sheet.getDefaultRowHeight());
+
+ wb = HSSFTestDataSamples.openSampleWorkbook( "34775.xls" );
+ // second and third sheets miss DefaultColWidthRecord
+ for(int i = 1; i <= 2; i++){
+ int dw = wb.getSheetAt( i ).getDefaultColumnWidth();
+ assertEquals(8, dw);
+ int cw = wb.getSheetAt( i ).getColumnWidth(0);
+ assertEquals(8*256, cw);
+
+ assertEquals(0xFF, sheet.getDefaultRowHeight());
+ }
+ }
+
/**
* Some utilities write Excel files without the ROW records.
* Excel, ooo, and google docs are OK with this.