UPDATE: I figured it out. Just needed to go to the first cell before the while statement. Everything above the Horizontal Rule is the update. Code below:
Code:
import de.bezier.data.*;
XlsReader reader;
String title;
ArrayList xls;
void setup ()
{
size( 600, 400 );
noStroke();
fill( 0 );
background( 255 );
smooth();
xls = new ArrayList();
reader = new XlsReader( this, "ohca.xls" );
reader.showWarnings(false);
reader.firstRow();
reader.firstCell();
title = reader.getString();
println(title);
while (reader.hasMoreRows()) {
reader.nextRow();
String r = reader.getString(); // Gather the row
if(r != null) {
int rL = r.length();
if( rL > 0 && r != "" ) {
reader.firstCell();
String f = reader.getString();
xls.add(f);
while( reader.hasMoreCells() ) {
reader.nextCell();
String c = reader.getString();
if(c != null) {
int cL = c.length();
if(cL > 0 && c != "") {
int pos = reader.getCellNum();
xls.add(c);
}
}
}
}
}
}
for(int i = xls.size() - 1; i >= 0; i--) {
String s = (String)xls.get(i);
println(s);
}
}
Enjoy!
Okay, so after some tinkering and thinking about this problem I think I was able to circumvent it sort of...Basically, an ArrayList won't be affected by these errors and null spaces. The ArrayList spits out just the content!
Code:
import de.bezier.data.*;
XlsReader reader;
String title;
ArrayList xls;
void setup ()
{
size( 600, 400 );
noStroke();
fill( 0 );
background( 255 );
smooth();
xls = new ArrayList();
reader = new XlsReader( this, "ohca.xls" );
reader.showWarnings(false);
reader.firstRow();
reader.firstCell();
title = reader.getString();
println(title);
while (reader.hasMoreRows()) {
reader.nextRow();
String r = reader.getString(); // Gather the row
if(r != null) {
int rL = r.length();
if( rL > 0 && r != "" ) {
while( reader.hasMoreCells() ) {
reader.nextCell();
String c = reader.getString();
if(c != null) {
int cL = c.length();
if(cL > 0 && c != "") {
int pos = reader.getCellNum();
xls.add(c);
}
}
}
}
}
}
for(int i = 0; i < 10; i++) {
String s = (String)xls.get(i);
println(s);
}
}
There is a new issue that has arisen however. While the method, nextCell(), in the documentation says, "Select the next (or first) cell of the selected row of current sheet," when I println out my ArrayList the first element, the name of the donor, doesn't display. Below is the println output and in red are the missing items:
Haiti Relief Contibution ListDonorChannel
Description
Funding
USD
Uncommitted
Pledges
USD
3MNGOs
Working with key humanitarian partners like Project HOPE and MAP International, 3M has donated numerous boxes and cases containing medical supplies such as Nexcare bandages, 3M Tegaderm transparent dressings, sterile drapes, splints, medical tapes and respiratory protection products. 3M continues to work closely with its nonprofit partners to identify other 3M products that may be needed.
1000000.0
0.0
UN Agencies, NGOs and Red Cross
In-kind: Donations of medicines and nutritional products
The items in red all happen to be in the first column of my excel document. Now at the moment I don't think it's the library, I think I must be skipping the first column somewhere, but if anyone has run in to this problem or can see what the issue is I would be much appreciative! As always you can find a zipped version of the pde with the documents here:
http://jonobr1.com/code/xlsreader3.zip