如何修改代码,使其仅打印单元格E和F?

时间:2015-05-03 01:57:25

标签: java excel

我在java上编写了一个小程序来读取excel,但是如何修改它以便只打印某些单元格?

public class Read
{
    public static void main(String [] args) throws Exception
    {
        File f = new File ("/users/Me/Documents/Test.xls");
        Workbook wb = Workbook.getWorkbook(f);
        Sheet s = wb.getSheet(0);
        int row = s.getRows();
        int col = s.getColumns();

        for(int i = 0; i<row;i++)
        {
            for(int j = 0; j<col;j++)
            {
                Cell c = s.getCell(j,i);
                System.out.print(c.getContents()+"\t");
            }
        }

        System.out.println("");
    }

}

0 个答案:

没有答案