View | Details | Raw Unified | Return to bug 34761
Collapse All | Expand All

(-)src/java/org/apache/poi/hssf/model/Sheet.java (+13 lines)
Lines 1934-1939 Link Here
1934
        return retval;
1934
        return retval;
1935
    }
1935
    }
1936
    
1936
    
1937
    public short getTopRow() 
1938
    {
1939
    	return (windowTwo==null) ? (short) 0 : windowTwo.getTopRow();
1940
    }
1941
    
1942
    public void setTopRow(short topRow) 
1943
    {
1944
    	if (windowTwo!=null) 
1945
    	{
1946
    		windowTwo.setTopRow(topRow);
1947
    	}
1948
    }
1949
    
1937
    /**
1950
    /**
1938
     * Returns the active row
1951
     * Returns the active row
1939
     *
1952
     *
(-)src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java (+22 lines)
Lines 871-876 Link Here
871
        sclRecord.setDenominator((short)denominator);
871
        sclRecord.setDenominator((short)denominator);
872
        getSheet().setSCLRecord(sclRecord);
872
        getSheet().setSCLRecord(sclRecord);
873
    }
873
    }
874
    
875
    /**
876
     * The top row in the visible view when the sheet is 
877
     * first viewed after opening it in a viewer (such as ms excel)
878
     * @return short indicating the rownum (0 based) of the top row
879
     */
880
    public short getTopRow() 
881
    {
882
    	return sheet.getTopRow();
883
    }
884
    
885
    /**
886
     * Sets the top row in the visible view of the sheet that shows
887
     * up on opening the sheet for viewing/editing in excel.
888
     * @param topRow row index (0 based) of the row that is shown 
889
     * on first viewing the sheet in a viewer (such as ms excel)
890
     */
891
    public void setTopRow(short topRow) 
892
    {
893
  		sheet.setTopRow(topRow);
894
    }
895
    
874
896
875
	/**
897
	/**
876
	 * Shifts the merged regions left or right depending on mode
898
	 * Shifts the merged regions left or right depending on mode
(-)src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java (-1 / +26 lines)
Lines 409-415 Link Here
409
        assertEquals ("DBCS Sheet Name 2", wb.getSheetName(1),"\u090f\u0915" );
409
        assertEquals ("DBCS Sheet Name 2", wb.getSheetName(1),"\u090f\u0915" );
410
        assertEquals("DBCS Sheet Name 1", wb.getSheetName(0),"\u091c\u093e");
410
        assertEquals("DBCS Sheet Name 1", wb.getSheetName(0),"\u091c\u093e");
411
    }
411
    }
412
	
412
    
413
    /**
414
     * Testing newly added method that exposes the WINDOW2.toprow
415
     * parameter to allow setting the toprow in the visible view
416
     * of the sheet when it is first opened.
417
     */
418
    public void testTopRow() throws Exception
419
    {
420
        FileInputStream fis = null;
421
        HSSFWorkbook wb     = null;
422
        
423
        String filename = System.getProperty("HSSF.testdata.path");
424
425
        filename = filename + "/SimpleWithPageBreaks.xls";
426
        fis = new FileInputStream(filename);
427
        wb = new HSSFWorkbook(fis);
428
        fis.close();
429
        
430
        HSSFSheet sheet = wb.getSheetAt(0);
431
        assertNotNull(sheet);
432
        
433
        short toprow = (short) 100;
434
        sheet.setTopRow(toprow);
435
        assertEquals("HSSFSheet.getTopRow()", toprow, sheet.getTopRow());
436
    }
437
    
413
	public static void main(java.lang.String[] args) {
438
	public static void main(java.lang.String[] args) {
414
		 junit.textui.TestRunner.run(TestHSSFSheet.class);
439
		 junit.textui.TestRunner.run(TestHSSFSheet.class);
415
	}    
440
	}    

Return to bug 34761