Hi,
I actually ran into the same problem and fixed it. I have included the patch. Basically, the program was jumping out of the loop too early when it is reading
in the data -- for some reason this happens around line 30/31.
I am not sure where to send this patch since this was originally a user-list subscription, so correct me if I am wrong to send it to this list.
thanks,
Anthony

Index: RowRecordsAggregate.java
===================================================================
RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java,v
retrieving revision 1.4
diff -u -r1.4 RowRecordsAggregate.java
--- RowRecordsAggregate.java 5 Sep 2002 00:26:26 -0000 1.4
+++ RowRecordsAggregate.java 21 Jan 2003 14:47:18 -0000
@@ -55,15 +55,17 @@

package org.apache.poi.hssf.record.aggregates;

+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.poi.hssf.record.LabelSSTRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RowRecord;
+import org.apache.poi.hssf.record.StringRecord;
import org.apache.poi.hssf.record.UnknownRecord;

-import java.util.Map;
-import java.util.TreeMap;
-import java.util.Iterator;
-import java.util.List;
-
/**
*
* @author andy
@@ -138,18 +140,31 @@
public int construct(int offset, List records)
{
int k = 0;
+ //System.out.println("Constructing rows:" + records.size());

for (k = offset; k < records.size(); k++)
{
Record rec = ( Record ) records.get(k);

- if (!rec.isInValueSection() && !(rec instanceof UnknownRecord))
+ // System.out.println("Record is of type: " + rec.getClass());
+ if (rec instanceof LabelSSTRecord) {
+ LabelSSTRecord new_name = (LabelSSTRecord) rec;
+ //System.out.println("Row for LabellSST: " + new_name.getRow());
+ }
+
+ if (rec instanceof StringRecord == false && !rec.isInValueSection() && !(rec instanceof UnknownRecord))
{
+ //System.out.println("Record is of type: " + rec.getClass());
+ // StringRecord r = (StringRecord)rec;
+ // System.out.println("String:" + r.getString());
break;
}
if (rec.getSid() == RowRecord.sid)
{
insertRow(( RowRecord ) rec);
+ RowRecord row = (RowRecord)rec;
+ // System.out.println("Row:" + row.getRowNumber());
+
}
}
return k;


Vikas Pathak wrote:

Hi,

I worked on this...But i didn't phase any problems.
Please go through the code let me know any doubts.

File filename = new File(filename1);
FileInputStream fin = new FileInputStream(filename);
HSSFWorkbook wb = new HSSFWorkbook(fin);
HSSFSheet sheet = wb.getSheetAt(sheetno);
Iterator rows = sheet.rowIterator();
HSSFRow r = (HSSFRow)rows.next();
while(r.getRowNum()<4)
r = (HSSFRow)rows.next();
rownum = r.getRowNum();

FileOutputStream fileout = new
FileOutputStream(filename);
HSSFCell cell;
HSSFCellStyle cs = wb.createCellStyle();
HSSFFont f2 = wb.createFont();
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits(2);
int dot;

r = sheet.createRow((short)(rownum+i));
cell = r.createCell((short)col);
cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
cell.setCellValue(xlval);
wb.write(fileout);
fileout.close();

Regards
kalpana.k


Amitabh Verma wrote:


Hi there,
I m using poi to read and append to mid size excel
files(around 2 MB) containing several sheets.
The following is the part of the code I use.
----------------------------------
for ( j =3;j<500; j++)
{
rowx = sheet.getRow(j);
if (rowx ==null) continue;
cell = rowx.getCell((short)6);
if (cell!=null)
{
yyy = cell.getStringCellValue();
-- some processing --
}
}
---------------------------------------
After around 30th row the "rowx = sheet.getRow(j)"
returns a null through I can see in the file that the
row is populated.
Now when create another XL file(which has 2 sheets in
all) by copying the same sheet it works fine.
Has any one faced this before.

Thanx and Regards
Amitabh

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>







--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to