Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #2694 > unrolled thread
| Started by | Paturi PRADEEP GOUD <paturi.pradeepgoud.mca@gmail.com> |
|---|---|
| First post | 2013-04-26 01:34 -0700 |
| Last post | 2013-04-26 08:04 -0700 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.java.help
How to delete a column from Excel File using java Paturi PRADEEP GOUD <paturi.pradeepgoud.mca@gmail.com> - 2013-04-26 01:34 -0700
Re: How to delete a column from Excel File using java Fred Kleinschmidt <fred.l.kleinschmidt@gmail.com> - 2013-04-26 08:04 -0700
| From | Paturi PRADEEP GOUD <paturi.pradeepgoud.mca@gmail.com> |
|---|---|
| Date | 2013-04-26 01:34 -0700 |
| Subject | How to delete a column from Excel File using java |
| Message-ID | <0d250d1e-8dd7-4640-a55e-62b2785266fb@googlegroups.com> |
I want to delete a column from Excel file using java. Following code I build to meet my requirement. but it is not working. Can anybody please help where I am going wrong.
public class Column
{
public static void main(String[] args)
{
Workbook wb = WorkbookFactory.create(new FileInputStream("Excel.xls"));
Sheet sheet = wb.getSheet("Failures");
Cell cell;
Column column;
Row row= sheet.getRow(0);
int numXolumns = row.getLastCellNum();
for(int col=0; col< numXolumns; col++)
{
cell = row.getCell(col);
String columnName = cell.getStringCellValue();
int Combo_index = 0;
if(columnName.contains("Combo".trim()))
{
Combo_index=cell.getColumnIndex();
sheet.removeRow(row);
}
}
}
}
[toc] | [next] | [standalone]
| From | Fred Kleinschmidt <fred.l.kleinschmidt@gmail.com> |
|---|---|
| Date | 2013-04-26 08:04 -0700 |
| Message-ID | <cc087eca-a45b-4120-a8eb-87a95ca22d03@googlegroups.com> |
| In reply to | #2694 |
On Friday, April 26, 2013 1:34:02 AM UTC-7, Paturi PRADEEP GOUD wrote:
> I want to delete a column from Excel file using java. Following code I build to meet my requirement. but it is not working. Can anybody please help where I am going wrong. public class Column { public static void main(String[] args) { Workbook wb = WorkbookFactory.create(new FileInputStream("Excel.xls")); Sheet sheet = wb.getSheet("Failures"); Cell cell; Column column; Row row= sheet.getRow(0); int numXolumns = row.getLastCellNum(); for(int col=0; col< numXolumns; col++) { cell = row.getCell(col); String columnName = cell.getStringCellValue(); int Combo_index = 0; if(columnName.contains("Combo".trim())) { Combo_index=cell.getColumnIndex(); sheet.removeRow(row); } } } }
Why not just use sheet.removeColumn( columnNumber ) ?
--
Fred K
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.help
csiph-web