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
30f56f14bc
commit
8f5847ee81
@ -1934,6 +1934,37 @@ public class Sheet implements Model
|
|||||||
return retval;
|
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
|
* Returns the active row
|
||||||
*
|
*
|
||||||
|
@ -872,6 +872,37 @@ public class HSSFSheet
|
|||||||
getSheet().setSCLRecord(sclRecord);
|
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
|
* Shifts the merged regions left or right depending on mode
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -410,6 +410,33 @@ public class TestHSSFSheet
|
|||||||
assertEquals("DBCS Sheet Name 1", wb.getSheetName(0),"\u091c\u093e");
|
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) {
|
public static void main(java.lang.String[] args) {
|
||||||
junit.textui.TestRunner.run(TestHSSFSheet.class);
|
junit.textui.TestRunner.run(TestHSSFSheet.class);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user