mirror of https://github.com/apache/poi.git
user API to set window pane when wb is opened
by Amol Deshmukh and Li Jianming git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353676 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c3b74a65d6
commit
588c498c5b
|
@ -1934,6 +1934,37 @@ public class Sheet implements Model
|
|||
return retval;
|
||||
}
|
||||
|
||||
public short getTopRow()
|
||||
{
|
||||
return (windowTwo==null) ? (short) 0 : windowTwo.getTopRow();
|
||||
}
|
||||
|
||||
public void setTopRow(short topRow)
|
||||
{
|
||||
if (windowTwo!=null)
|
||||
{
|
||||
windowTwo.setTopRow(topRow);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the left column to show in desktop window pane.
|
||||
* @param the left column to show in desktop window pane
|
||||
*/
|
||||
public void setLeftCol(short leftCol){
|
||||
if (windowTwo!=null)
|
||||
{
|
||||
windowTwo.setLeftCol(leftCol);
|
||||
}
|
||||
}
|
||||
|
||||
public short getLeftCol()
|
||||
{
|
||||
return (windowTwo==null) ? (short) 0 : windowTwo.getLeftCol();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the active row
|
||||
*
|
||||
|
|
|
@ -871,6 +871,37 @@ public class HSSFSheet
|
|||
sclRecord.setDenominator((short)denominator);
|
||||
getSheet().setSCLRecord(sclRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* The top row in the visible view when the sheet is
|
||||
* first viewed after opening it in a viewer
|
||||
* @return short indicating the rownum (0 based) of the top row
|
||||
*/
|
||||
public short getTopRow()
|
||||
{
|
||||
return sheet.getTopRow();
|
||||
}
|
||||
|
||||
/**
|
||||
* The left col in the visible view when the sheet is
|
||||
* first viewed after opening it in a viewer
|
||||
* @return short indicating the rownum (0 based) of the top row
|
||||
*/
|
||||
public short getLeftCol()
|
||||
{
|
||||
return sheet.getLeftCol();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets desktop window pane display area, when the
|
||||
* file is first opened in a viewer.
|
||||
* @param the top row to show in desktop window pane
|
||||
* @param the left column to show in desktop window pane
|
||||
*/
|
||||
public void showInPane(short toprow, short leftcol){
|
||||
this.sheet.setTopRow((short)toprow);
|
||||
this.sheet.setLeftCol((short)leftcol);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shifts the merged regions left or right depending on mode
|
||||
|
|
|
@ -409,7 +409,34 @@ public class TestHSSFSheet
|
|||
assertEquals ("DBCS Sheet Name 2", wb.getSheetName(1),"\u090f\u0915" );
|
||||
assertEquals("DBCS Sheet Name 1", wb.getSheetName(0),"\u091c\u093e");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Testing newly added method that exposes the WINDOW2.toprow
|
||||
* parameter to allow setting the toprow in the visible view
|
||||
* of the sheet when it is first opened.
|
||||
*/
|
||||
public void testTopRow() throws Exception
|
||||
{
|
||||
FileInputStream fis = null;
|
||||
HSSFWorkbook wb = null;
|
||||
|
||||
String filename = System.getProperty("HSSF.testdata.path");
|
||||
|
||||
filename = filename + "/SimpleWithPageBreaks.xls";
|
||||
fis = new FileInputStream(filename);
|
||||
wb = new HSSFWorkbook(fis);
|
||||
fis.close();
|
||||
|
||||
HSSFSheet sheet = wb.getSheetAt(0);
|
||||
assertNotNull(sheet);
|
||||
|
||||
short toprow = (short) 100;
|
||||
short leftcol = (short) 50;
|
||||
sheet.showInPane(toprow,leftcol);
|
||||
assertEquals("HSSFSheet.getTopRow()", toprow, sheet.getTopRow());
|
||||
assertEquals("HSSFSheet.getLeftCol()", leftcol, sheet.getLeftCol());
|
||||
}
|
||||
|
||||
public static void main(java.lang.String[] args) {
|
||||
junit.textui.TestRunner.run(TestHSSFSheet.class);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue