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:
Avik Sengupta 2005-05-07 17:25:26 +00:00
parent 30f56f14bc
commit 8f5847ee81
3 changed files with 90 additions and 1 deletions

View File

@ -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
* *

View File

@ -871,6 +871,37 @@ public class HSSFSheet
sclRecord.setDenominator((short)denominator); sclRecord.setDenominator((short)denominator);
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

View File

@ -409,7 +409,34 @@ public class TestHSSFSheet
assertEquals ("DBCS Sheet Name 2", wb.getSheetName(1),"\u090f\u0915" ); assertEquals ("DBCS Sheet Name 2", wb.getSheetName(1),"\u090f\u0915" );
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);
} }