java 表格增删改查

2025-01-03 11:43:03
推荐回答(2个)
回答1:

import java.util.*;
import java.text.*;
import java.io.*;
import jxl.*;
public class jxl
{
public static void main(String[] args)
{
String fileName = "c://signupcheckin.xls";
InputStream is = null;
FileInputStream fn = null;
int cs = 0;
int rs = 0;
try{
fn = new FileInputStream(fileName);
is = fn;
Workbook rb = Workbook.getWorkbook(is);
Sheet s = rb.getSheet(0);//此处只读取第一个sheet内容
Cell a2=s.getCell(0,1); //此处是获取单个单元格的数据
Cell c4=s.getCell(2,3);
String sa2=a2.getContents();
String sc4=c4.getContents();
System.out.println(sa2+" "+sc4);
System.out.print("\n\n\n");
cs = s.getColumns();
rs = s.getRows();
for(int j=0;j Cell[] c = s.getRow(j);
for(int x=0;x System.out.print(c[x].getContents()+"\t");
}
System.out.print("\r\n");
}
System.out.println("Columns:"+cs+" Rows:"+rs);
}catch(Exception e){
System.out.println(e.toString());
}finally{
try{
fn.close();
is.close();
}catch(Exception e){
System.out.println(e.toString());
}
}
}
}

回答2:

从TableModel中处理。。。。。。。。