gudii9
asked on
java program reading the spreadsheet document data
My java program looks like this
Name | Number
CS020 | 7120917302
HE030 | 18533976
PF044 | 7116244216
|
|
|
|
|
|
|
My program is displaying the First row also which is heading. I do not want to display the heading. I would like skip first row. Also my program priniting pipe character many times after printing 3 rows of data from excel spread sheet. Please advise on how can I fix these two issues.Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance
import java.io.File;Console output looks like this
import java.io.IOException;
import jxl.Cell;
import jxl.CellType;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class ReadExcel {
private String inputFile;
public void setInputFile(String inputFile) {
this.inputFile = inputFile;
}
public void read() throws IOException {
File inputWorkbook = new File(inputFile);
Workbook w;
try {
w = Workbook.getWorkbook(inputWorkbook);
// Get the first sheet
Sheet sheet = w.getSheet(0);
// Loop over first 10 column and lines
System.out.println(sheet.getRows());
for (int i = 0; i < sheet.getRows(); i++) {
for (int j = 0; j < sheet.getColumns(); j++) {
Cell cell = sheet.getCell(i, j);
String x = cell.getContents();
System.out.println(x);
}
}
} catch (BiffException e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws IOException {
ReadExcel test = new ReadExcel();
test.setInputFile("c:/gp/Report.xls" );
test.read();
}
}
Name | Number
CS020 | 7120917302
HE030 | 18533976
PF044 | 7116244216
|
|
|
|
|
|
|
My program is displaying the First row also which is heading. I do not want to display the heading. I would like skip first row. Also my program priniting pipe character many times after printing 3 rows of data from excel spread sheet. Please advise on how can I fix these two issues.Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
How tp unformat for unwanted rows please advise
ASKER
I see one issue
it is printing
CS020 | 7120917302
HE030 | 18533976
PF044 | 7116244216
CS020 | 7120917302
HE030 | 18533976
PF044 | 7116244216
two times as the number of columns is 2. (i want to display only one time).How to fix this issue. Please advise
it is printing
CS020 | 7120917302
HE030 | 18533976
PF044 | 7116244216
CS020 | 7120917302
HE030 | 18533976
PF044 | 7116244216
two times as the number of columns is 2. (i want to display only one time).How to fix this issue. Please advise
ASKER
Reportt.xls