Merge from 1.5 branch

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352513 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Glen Stampoultzis 2002-04-28 05:22:19 +00:00
parent 299fcceb90
commit 58a0ff577e
2 changed files with 36 additions and 19 deletions

View File

@ -318,6 +318,9 @@ public class HSSFRow
public short getFirstCellNum() public short getFirstCellNum()
{ {
if (getPhysicalNumberOfCells() == 0)
return -1;
else
return row.getFirstCol(); return row.getFirstCol();
} }
@ -328,6 +331,9 @@ public class HSSFRow
public short getLastCellNum() public short getLastCellNum()
{ {
if (getPhysicalNumberOfCells() == 0)
return -1;
else
return row.getLastCol(); return row.getLastCol();
} }

View File

@ -55,7 +55,10 @@
package org.apache.poi.hssf.usermodel; package org.apache.poi.hssf.usermodel;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.poi.hssf.record.RowRecord;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
/** /**
* Test HSSFRow is okay. * Test HSSFRow is okay.
@ -87,15 +90,10 @@ public class TestHSSFRow
assertEquals(1, row.getFirstCellNum()); assertEquals(1, row.getFirstCellNum());
assertEquals(2, row.getLastCellNum()); assertEquals(2, row.getLastCellNum());
RowRecord rowRecord = new RowRecord();
rowRecord.setFirstCol((short) 2);
rowRecord.setLastCol((short) 5);
row = new HSSFRow(workbook.getWorkbook(), sheet.getSheet(), rowRecord);
assertEquals(2, row.getFirstCellNum());
assertEquals(5, row.getLastCellNum());
} }
public void testRemoveCell() public void testRemoveCell()
throws Exception
{ {
HSSFWorkbook workbook = new HSSFWorkbook(); HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet(); HSSFSheet sheet = workbook.createSheet();
@ -121,5 +119,18 @@ public class TestHSSFRow
assertEquals(0, data[6]); assertEquals(0, data[6]);
assertEquals(0, data[8]); assertEquals(0, data[8]);
File file = File.createTempFile("XXX", "XLS");
FileOutputStream stream = new FileOutputStream(file);
workbook.write(stream);
stream.close();
FileInputStream inputStream = new FileInputStream(file);
workbook = new HSSFWorkbook(inputStream);
sheet = workbook.getSheetAt(0);
stream.close();
file.delete();
assertEquals(-1, sheet.getRow((short) 0).getLastCellNum());
assertEquals(-1, sheet.getRow((short) 0).getFirstCellNum());
} }
} }